mirror of
https://github.com/wekan/wekan.git
synced 2026-02-21 07:24:07 +01:00
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration: - Add await before all ReactiveCache.getX() calls - Make functions containing ReactiveCache calls async - Convert forEach/map/filter loops with async callbacks to for...of - Update model helpers, Meteor methods, JsonRoutes handlers - Update collection hooks (.before/.after insert/update/remove) - Update .allow() callbacks to async Files updated across models/ and server/ directories: - Model files: cards, boards, lists, swimlanes, activities, users, checklists, checklistItems, customFields, attachments, integrations, cardComments, settings files, creators, exporters, and more - Server files: publications, methods, notifications, routes, migrations
This commit is contained in:
parent
2f6e34c5f5
commit
71eb01e233
81 changed files with 2218 additions and 2148 deletions
|
|
@ -33,8 +33,8 @@ Meteor.startup(() => {
|
|||
// Meteor.setTimeout(func, delay) does not accept args :-(
|
||||
// so we pass userId with closure
|
||||
const userId = user._id;
|
||||
Meteor.setTimeout(() => {
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
Meteor.setTimeout(async () => {
|
||||
const user = await ReactiveCache.getUser(userId);
|
||||
|
||||
// for each user, in the timed period, only the first call will get the cached content,
|
||||
// other calls will get nothing
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ Notifications = {
|
|||
delete notifyServices[serviceName];
|
||||
},
|
||||
|
||||
getUsers: watchers => {
|
||||
getUsers: async watchers => {
|
||||
const users = [];
|
||||
watchers.forEach(userId => {
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
for (const userId of watchers) {
|
||||
const user = await ReactiveCache.getUser(userId);
|
||||
if (user && user._id) users.push(user);
|
||||
});
|
||||
}
|
||||
return users;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -70,20 +70,20 @@ if (Meteor.isServer) {
|
|||
'label',
|
||||
'attachmentId',
|
||||
];
|
||||
const responseFunc = data => {
|
||||
const responseFunc = async data => {
|
||||
const paramCommentId = data.commentId;
|
||||
const paramCardId = data.cardId;
|
||||
const paramBoardId = data.boardId;
|
||||
const newComment = data.comment;
|
||||
if (paramCardId && paramBoardId && newComment) {
|
||||
// only process data with the cardid, boardid and comment text, TODO can expand other functions here to react on returned data
|
||||
const comment = ReactiveCache.getCardComment({
|
||||
const comment = await ReactiveCache.getCardComment({
|
||||
_id: paramCommentId,
|
||||
cardId: paramCardId,
|
||||
boardId: paramBoardId,
|
||||
});
|
||||
const board = ReactiveCache.getBoard(paramBoardId);
|
||||
const card = ReactiveCache.getCard(paramCardId);
|
||||
const board = await ReactiveCache.getBoard(paramBoardId);
|
||||
const card = await ReactiveCache.getCard(paramCardId);
|
||||
if (board && card) {
|
||||
if (comment) {
|
||||
Lock.set(comment._id, newComment);
|
||||
|
|
@ -108,8 +108,8 @@ if (Meteor.isServer) {
|
|||
}
|
||||
};
|
||||
Meteor.methods({
|
||||
outgoingWebhooks(integration, description, params) {
|
||||
if (ReactiveCache.getCurrentUser()) {
|
||||
async outgoingWebhooks(integration, description, params) {
|
||||
if (await ReactiveCache.getCurrentUser()) {
|
||||
check(integration, Object);
|
||||
check(description, String);
|
||||
check(params, Object);
|
||||
|
|
@ -137,7 +137,7 @@ if (Meteor.isServer) {
|
|||
});
|
||||
|
||||
const userId = params.userId ? params.userId : integrations[0].userId;
|
||||
const user = ReactiveCache.getUser(userId);
|
||||
const user = await ReactiveCache.getUser(userId);
|
||||
const descriptionText = TAPi18n.__(
|
||||
description,
|
||||
quoteParams,
|
||||
|
|
@ -171,7 +171,7 @@ if (Meteor.isServer) {
|
|||
data: is2way ? { description, ...clonedParams } : value,
|
||||
};
|
||||
|
||||
if (!ReactiveCache.getIntegration({ url: integration.url })) return;
|
||||
if (!(await ReactiveCache.getIntegration({ url: integration.url }))) return;
|
||||
|
||||
const url = integration.url;
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ if (Meteor.isServer) {
|
|||
const data = response.data; // only an JSON encoded response will be actioned
|
||||
if (data) {
|
||||
try {
|
||||
responseFunc(data);
|
||||
await responseFunc(data);
|
||||
} catch (e) {
|
||||
throw new Meteor.Error('error-process-data');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@ Meteor.methods({
|
|||
let watchableObj = null;
|
||||
let board = null;
|
||||
if (watchableType === 'board') {
|
||||
watchableObj = ReactiveCache.getBoard(id);
|
||||
watchableObj = await ReactiveCache.getBoard(id);
|
||||
if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
|
||||
board = watchableObj;
|
||||
} else if (watchableType === 'list') {
|
||||
watchableObj = ReactiveCache.getList(id);
|
||||
watchableObj = await ReactiveCache.getList(id);
|
||||
if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist');
|
||||
board = watchableObj.board();
|
||||
board = await watchableObj.board();
|
||||
} else if (watchableType === 'card') {
|
||||
watchableObj = ReactiveCache.getCard(id);
|
||||
watchableObj = await ReactiveCache.getCard(id);
|
||||
if (!watchableObj) throw new Meteor.Error('error-card-doesNotExist');
|
||||
board = watchableObj.board();
|
||||
board = await watchableObj.board();
|
||||
} else {
|
||||
throw new Meteor.Error('error-json-schema');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue