From a182482cfbac8eccaa7d60a80f4da4d351c2a1f9 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Sat, 14 Jan 2023 13:29:57 +0100 Subject: [PATCH] Move every Boards.findOne(boardId) to the ReactiveCache (Part 2) --- client/components/activities/activities.js | 3 +- client/components/boards/boardsList.js | 9 +-- client/components/cards/cardDetails.js | 3 +- client/components/cards/checklists.js | 5 +- client/components/cards/subtasks.js | 4 +- client/components/lists/listBody.js | 14 ++--- client/components/settings/attachments.js | 5 +- client/components/sidebar/sidebar.js | 3 +- client/lib/dialogWithBoardSwimlaneList.js | 10 ++-- client/lib/keyboard.js | 6 +- client/lib/utils.js | 4 +- models/actions.js | 7 ++- models/activities.js | 8 ++- models/attachments.js | 9 +-- models/attachments_old.js | 10 ++-- models/boards.js | 11 ++-- models/cardCommentReactions.js | 8 ++- models/cardComments.js | 7 ++- models/cards.js | 68 +++++++++++----------- models/checklists.js | 5 +- models/csvCreator.js | 5 +- models/customFields.js | 4 +- models/exporter.js | 5 +- models/integrations.js | 4 +- models/lists.js | 11 ++-- models/rules.js | 9 +-- models/swimlanes.js | 13 +++-- models/trelloCreator.js | 3 +- models/triggers.js | 7 ++- models/users.js | 8 +-- models/wekanCreator.js | 3 +- sandstorm.js | 3 +- server/authentication.js | 3 +- server/notifications/outgoing.js | 3 +- server/notifications/watch.js | 4 +- server/publications/boards.js | 3 +- server/publications/swimlanes.js | 6 +- 37 files changed, 166 insertions(+), 127 deletions(-) diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js index ac4329c00..2696c7851 100644 --- a/client/components/activities/activities.js +++ b/client/components/activities/activities.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import DOMPurify from 'dompurify'; import { TAPi18n } from '/imports/i18n'; @@ -145,7 +146,7 @@ BlazeComponent.extendComponent({ lastLabel() { const lastLabelId = this.currentData().activity.labelId; if (!lastLabelId) return null; - const lastLabel = Boards.findOne( + const lastLabel = ReactiveCache.getBoard( this.currentData().activity.boardId, ).getLabelById(lastLabelId); if (lastLabel && (lastLabel.name === undefined || lastLabel.name === '')) { diff --git a/client/components/boards/boardsList.js b/client/components/boards/boardsList.js index dab897c19..77201e3ad 100644 --- a/client/components/boards/boardsList.js +++ b/client/components/boards/boardsList.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { TAPi18n } from '/imports/i18n'; const subManager = new SubsManager(); @@ -223,8 +224,8 @@ BlazeComponent.extendComponent({ boardMembers(boardId) { let boardMembers = []; /* Bug Board icons random dance https://github.com/wekan/wekan/issues/4214 - const lists = Boards.findOne({ '_id': boardId }) - let members = lists.members; + const lists = ReactiveCache.getBoard(boardId) + let members = lists.members members.forEach(member => { boardMembers.push(member.userId); }); @@ -266,14 +267,14 @@ BlazeComponent.extendComponent({ evt.preventDefault(); }, 'click .js-clone-board'(evt) { - let title = getSlug(Boards.findOne(this.currentData()._id).title) || 'cloned-board'; + let title = getSlug(ReactiveCache.getBoard(this.currentData()._id).title) || 'cloned-board'; Meteor.call( 'copyBoard', this.currentData()._id, { sort: Boards.find({ archived: false }).count(), type: 'board', - title: Boards.findOne(this.currentData()._id).title, + title: ReactiveCache.getBoard(this.currentData()._id).title, }, (err, res) => { if (err) { diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index e16e915df..bbb652e72 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import moment from 'moment/min/moment-with-locales'; import { TAPi18n } from '/imports/i18n'; import { DatePicker } from '/client/lib/datepicker'; @@ -143,7 +144,7 @@ BlazeComponent.extendComponent({ const card = this.currentData(); let result = '#'; if (card) { - const board = Boards.findOne(card.boardId); + const board = ReactiveCache.getBoard(card.boardId); if (board) { result = FlowRouter.path('card', { boardId: card.boardId, diff --git a/client/components/cards/checklists.js b/client/components/cards/checklists.js index fb2093030..7848736c3 100644 --- a/client/components/cards/checklists.js +++ b/client/components/cards/checklists.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { TAPi18n } from '/imports/i18n'; import Cards from '/models/cards'; import Boards from '/models/boards'; @@ -243,12 +244,12 @@ BlazeComponent.extendComponent({ }, swimlanes() { - const board = Boards.findOne(this.selectedBoardId.get()); + const board = ReactiveCache.getBoard(this.selectedBoardId.get()); return board.swimlanes(); }, aBoardLists() { - const board = Boards.findOne(this.selectedBoardId.get()); + const board = ReactiveCache.getBoard(this.selectedBoardId.get()); return board.lists(); }, diff --git a/client/components/cards/subtasks.js b/client/components/cards/subtasks.js index 2b1615729..5059b81a9 100644 --- a/client/components/cards/subtasks.js +++ b/client/components/cards/subtasks.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + BlazeComponent.extendComponent({ addSubtask(event) { event.preventDefault(); @@ -6,7 +8,7 @@ BlazeComponent.extendComponent({ const cardId = this.currentData().cardId; const card = Cards.findOne(cardId); const sortIndex = -1; - const crtBoard = Boards.findOne(card.boardId); + const crtBoard = ReactiveCache.getBoard(card.boardId); const targetBoard = crtBoard.getDefaultSubtasksBoard(); const listId = targetBoard.getDefaultSubtasksListId(); diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 92de5a66f..d14f9182b 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { TAPi18n } from '/imports/i18n'; import { Spinner } from '/client/lib/spinner'; @@ -269,7 +270,7 @@ BlazeComponent.extendComponent({ const currentBoardId = Session.get('currentBoard'); arr = []; _.forEach( - Boards.findOne(currentBoardId) + ReactiveCache.getBoard(currentBoardId) .customFields() .fetch(), function (field) { @@ -288,8 +289,8 @@ BlazeComponent.extendComponent({ getLabels() { const currentBoardId = Session.get('currentBoard'); - if (Boards.findOne(currentBoardId).labels) { - return Boards.findOne(currentBoardId).labels.filter(label => { + if (ReactiveCache.getBoard(currentBoardId).labels) { + return ReactiveCache.getBoard(currentBoardId).labels.filter(label => { return this.labels.get().indexOf(label._id) > -1; }); } @@ -430,7 +431,7 @@ BlazeComponent.extendComponent({ this.boardId = Session.get('currentBoard'); // In order to get current board info subManager.subscribe('board', this.boardId, false); - this.board = Boards.findOne(this.boardId); + this.board = ReactiveCache.getBoard(this.boardId); // List where to insert card const list = $(Popup._getTopStack().openerElement).closest('.js-list'); this.listId = Blaze.getData(list[0])._id; @@ -589,7 +590,6 @@ BlazeComponent.extendComponent({ this.isBoardTemplateSearch; let board = {}; if (this.isTemplateSearch) { - //board = Boards.findOne((Meteor.user().profile || {}).templatesBoardId); board._id = (Meteor.user().profile || {}).templatesBoardId; } else { // Prefetch first non-current board id @@ -651,7 +651,7 @@ BlazeComponent.extendComponent({ if (!this.selectedBoardId) { return []; } - const board = Boards.findOne(this.selectedBoardId.get()); + const board = ReactiveCache.getBoard(this.selectedBoardId.get()); if (!this.isTemplateSearch || this.isCardTemplateSearch) { return board.searchCards(this.term.get(), false); } else if (this.isListTemplateSearch) { @@ -713,7 +713,7 @@ BlazeComponent.extendComponent({ element.type = 'list'; _id = element.copy(this.boardId, this.swimlaneId); } else if (this.isSwimlaneTemplateSearch) { - element.sort = Boards.findOne(this.boardId) + element.sort = ReactiveCache.getBoard(this.boardId) .swimlanes() .count(); element.type = 'swimlane'; diff --git a/client/components/settings/attachments.js b/client/components/settings/attachments.js index 1d72342e2..6982c2f32 100644 --- a/client/components/settings/attachments.js +++ b/client/components/settings/attachments.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import Attachments, { fileStoreStrategyFactory } from '/models/attachments'; const filesize = require('filesize'); @@ -61,14 +62,14 @@ BlazeComponent.extendComponent({ return _version; }); }); - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); board.attachments = boardAttachments; return board; }) return ret; }, getBoardData(boardid) { - const ret = Boards.findOne(boardId); + const ret = ReactiveCache.getBoard(boardId); return ret; }, events() { diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index 9db5bb4cc..f9e18d046 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { TAPi18n } from '/imports/i18n'; Sidebar = null; @@ -284,7 +285,7 @@ Template.memberPopup.events({ Cards.find({ boardId, assignees: memberId }).forEach(card => { card.unassignAssignee(memberId); }); - Boards.findOne(boardId).removeMember(memberId); + ReactiveCache.getBoard(boardId).removeMember(memberId); Popup.back(); }), 'click .js-leave-member': Popup.afterConfirm('leaveBoard', () => { diff --git a/client/lib/dialogWithBoardSwimlaneList.js b/client/lib/dialogWithBoardSwimlaneList.js index ec41aca95..8b5eeafbb 100644 --- a/client/lib/dialogWithBoardSwimlaneList.js +++ b/client/lib/dialogWithBoardSwimlaneList.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + export class DialogWithBoardSwimlaneList extends BlazeComponent { /** returns the card dialog options * @return Object with properties { boardId, swimlaneId, listId } @@ -62,7 +64,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent { /** sets the first swimlane id */ setFirstSwimlaneId() { try { - const board = Boards.findOne(this.selectedBoardId.get()); + const board = ReactiveCache.getBoard(this.selectedBoardId.get()); const swimlaneId = board.swimlanes().fetch()[0]._id; this.selectedSwimlaneId.set(swimlaneId); } catch (e) {} @@ -70,7 +72,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent { /** sets the first list id */ setFirstListId() { try { - const board = Boards.findOne(this.selectedBoardId.get()); + const board = ReactiveCache.getBoard(this.selectedBoardId.get()); const listId = board.lists().fetch()[0]._id; this.selectedListId.set(listId); } catch (e) {} @@ -120,14 +122,14 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent { /** returns all available swimlanes of the current board */ swimlanes() { - const board = Boards.findOne(this.selectedBoardId.get()); + const board = ReactiveCache.getBoard(this.selectedBoardId.get()); const ret = board.swimlanes(); return ret; } /** returns all available lists of the current board */ lists() { - const board = Boards.findOne(this.selectedBoardId.get()); + const board = ReactiveCache.getBoard(this.selectedBoardId.get()); const ret = board.lists(); return ret; } diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index 5fcea4566..e2c47eedd 100644 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + // XXX There is no reason to define these shortcuts globally, they should be // attached to a template (most of them will go in the `board` template). @@ -76,7 +78,7 @@ Mousetrap.bind(numbArray, (evt, key) => { return; } const currentBoardId = Session.get('currentBoard'); - board = Boards.findOne(currentBoardId); + board = ReactiveCache.getBoard(currentBoardId); labels = board.labels; if(MultiSelection.isActive()) { @@ -100,7 +102,7 @@ Mousetrap.bind(numArray, (evt, key) => { if (currentUserId === null) { return; } - board = Boards.findOne(currentBoardId); + board = ReactiveCache.getBoard(currentBoardId); labels = board.labels; if(MultiSelection.isActive() && Meteor.user().isBoardMember()) { diff --git a/client/lib/utils.js b/client/lib/utils.js index c21bedcea..b13ed40ef 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -201,7 +201,7 @@ Utils = { // XXX We should remove these two methods goBoardId(_id) { - const board = Boards.findOne(_id); + const board = ReactiveCache.getBoard(_id); return ( board && FlowRouter.go('board', { @@ -213,7 +213,7 @@ Utils = { goCardId(_id) { const card = Cards.findOne(_id); - const board = Boards.findOne(card.boardId); + const board = ReactiveCache.getBoard(card.boardId); return ( board && FlowRouter.go('card', { diff --git a/models/actions.js b/models/actions.js index 20bc4a869..cb79181e6 100644 --- a/models/actions.js +++ b/models/actions.js @@ -1,16 +1,17 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { Meteor } from 'meteor/meteor'; Actions = new Mongo.Collection('actions'); Actions.allow({ insert(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, }); diff --git a/models/activities.js b/models/activities.js index 6803a9873..93b27f36a 100644 --- a/models/activities.js +++ b/models/activities.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + // Activities don't need a schema because they are always set from the a trusted // environment - the server - and there is no risk that a user change the logic // we use with this collection. Moreover using a schema for this collection @@ -12,10 +14,10 @@ Activities = new Mongo.Collection('activities'); Activities.helpers({ board() { - return Boards.findOne(this.boardId); + return ReactiveCache.getBoard(this.boardId); }, oldBoard() { - return Boards.findOne(this.oldBoardId); + return ReactiveCache.getBoard(this.oldBoardId); }, user() { return Users.findOne(this.userId); @@ -108,7 +110,7 @@ if (Meteor.isServer) { let participants = []; let watchers = []; let title = 'act-activity-notify'; - const board = Boards.findOne(activity.boardId); + const board = ReactiveCache.getBoard(activity.boardId); const description = `act-${activity.activityType}`; const params = { activityId: activity._id, diff --git a/models/attachments.js b/models/attachments.js index 71294f2a6..93e036c4c 100644 --- a/models/attachments.js +++ b/models/attachments.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { Meteor } from 'meteor/meteor'; import { FilesCollection } from 'meteor/ostrio:files'; import { isFileValid } from './fileValidation'; @@ -122,7 +123,7 @@ Attachments = new FilesCollection({ return false; } - const board = Boards.findOne(fileObj.meta.boardId); + const board = ReactiveCache.getBoard(fileObj.meta.boardId); if (board.isPublic()) { return true; } @@ -134,13 +135,13 @@ Attachments = new FilesCollection({ if (Meteor.isServer) { Attachments.allow({ insert(userId, fileObj) { - return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId)); }, update(userId, fileObj) { - return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId)); }, remove(userId, fileObj) { - return allowIsBoardMember(userId, Boards.findOne(fileObj.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(fileObj.boardId)); }, fetch: ['meta'], }); diff --git a/models/attachments_old.js b/models/attachments_old.js index 3ef8a388e..fae4b844c 100644 --- a/models/attachments_old.js +++ b/models/attachments_old.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + const storeName = 'attachments'; const defaultStoreOptions = { beforeWrite: fileObj => { @@ -35,19 +37,19 @@ if (Meteor.isServer) { AttachmentsOld.allow({ insert(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, // We authorize the attachment download either: // - if the board is public, everyone (even unconnected) can download it // - if the board is private, only board members can download it download(userId, doc) { - const board = Boards.findOne(doc.boardId); + const board = ReactiveCache.getBoard(doc.boardId); if (board.isPublic()) { return true; } else { diff --git a/models/boards.js b/models/boards.js index 763b83c7b..fb573be13 100644 --- a/models/boards.js +++ b/models/boards.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import escapeForRegex from 'escape-string-regexp'; import { TAPi18n } from '/imports/i18n'; import { @@ -1124,7 +1125,7 @@ Boards.helpers({ }, getDefaultSubtasksBoard() { - return Boards.findOne(this.getDefaultSubtasksBoardId()); + return ReactiveCache.getBoard(this.getDefaultSubtasksBoardId()); }, //Date Settings option such as received date, start date and so on. @@ -1157,7 +1158,7 @@ Boards.helpers({ }, getDefaultDateSettingsBoard() { - return Boards.findOne(this.getDefaultDateSettingsBoardId()); + return ReactiveCache.getBoard(this.getDefaultDateSettingsBoardId()); }, getDefaultSubtasksListId() { @@ -1696,7 +1697,7 @@ if (Meteor.isServer) { }, quitBoard(boardId) { check(boardId, String); - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); if (board) { const userId = Meteor.userId(); const index = board.memberIndex(userId); @@ -1708,7 +1709,7 @@ if (Meteor.isServer) { }, acceptInvite(boardId) { check(boardId, String); - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); if (!board) { throw new Meteor.Error('error-board-doesNotExist'); } @@ -1749,7 +1750,7 @@ if (Meteor.isServer) { Meteor.methods({ archiveBoard(boardId) { check(boardId, String); - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); if (board) { const userId = Meteor.userId(); const index = board.memberIndex(userId); diff --git a/models/cardCommentReactions.js b/models/cardCommentReactions.js index 9975f3a2b..5e9e23251 100644 --- a/models/cardCommentReactions.js +++ b/models/cardCommentReactions.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + const commentReactionSchema = new SimpleSchema({ reactionCodepoint: { type: String, @@ -49,13 +51,13 @@ CardCommentReactions.attachSchema( CardCommentReactions.allow({ insert(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, fetch: ['boardId'], }); diff --git a/models/cardComments.js b/models/cardComments.js index 829649126..954f25d9c 100644 --- a/models/cardComments.js +++ b/models/cardComments.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import escapeForRegex from 'escape-string-regexp'; import DOMPurify from 'dompurify'; @@ -74,13 +75,13 @@ CardComments.attachSchema( CardComments.allow({ insert(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc) { - return userId === doc.userId || allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return userId === doc.userId || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, remove(userId, doc) { - return userId === doc.userId || allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return userId === doc.userId || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, fetch: ['userId', 'boardId'], }); diff --git a/models/cards.js b/models/cards.js index 78878d486..73bb5214e 100644 --- a/models/cards.js +++ b/models/cards.js @@ -490,19 +490,19 @@ Cards.attachSchema( Cards.allow({ insert(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc, fields) { // Allow board members or logged in users if only vote get's changed return ( - allowIsBoardMember(userId, Boards.findOne(doc.boardId)) || + allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)) || (_.isEqual(fields, ['vote', 'modifiedAt', 'dateLastActivity']) && !!userId) ); }, remove(userId, doc) { - return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMember(userId, ReactiveCache.getBoard(doc.boardId)); }, fetch: ['boardId'], }); @@ -1093,7 +1093,7 @@ Cards.helpers({ if (card && card.description) return card.description; else return null; } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board && board.description) return board.description; else return null; } else if (this.description) { @@ -1112,7 +1112,7 @@ Cards.helpers({ return card.members; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1134,7 +1134,7 @@ Cards.helpers({ return card.assignees; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1150,7 +1150,7 @@ Cards.helpers({ assignMember(memberId) { let ret; if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); ret = board.addMember(memberId); } else { ret = Cards.update( @@ -1168,7 +1168,7 @@ Cards.helpers({ { $addToSet: { assignees: assigneeId } }, ); } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); return board.addAssignee(assigneeId); } else { return Cards.update( @@ -1185,7 +1185,7 @@ Cards.helpers({ { $pull: { members: memberId } }, ); } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); return board.removeMember(memberId); } else { return Cards.update({ _id: this._id }, { $pull: { members: memberId } }); @@ -1199,7 +1199,7 @@ Cards.helpers({ { $pull: { assignees: assigneeId } }, ); } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); return board.removeAssignee(assigneeId); } else { return Cards.update( @@ -1234,7 +1234,7 @@ Cards.helpers({ return card.receivedAt; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1262,7 +1262,7 @@ Cards.helpers({ return card.startAt; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1290,7 +1290,7 @@ Cards.helpers({ return card.dueAt; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1318,7 +1318,7 @@ Cards.helpers({ return card.endAt; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1346,7 +1346,7 @@ Cards.helpers({ return card.isOvertime; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1374,7 +1374,7 @@ Cards.helpers({ return card.spentTime; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1404,7 +1404,7 @@ Cards.helpers({ return null; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else if (board && board.vote) { @@ -1430,7 +1430,7 @@ Cards.helpers({ return null; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else if (board && board.vote) { @@ -1456,7 +1456,7 @@ Cards.helpers({ return null; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else if (board && board.vote) { @@ -1516,7 +1516,7 @@ Cards.helpers({ return null; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else if (board && board.poker) { @@ -1550,7 +1550,7 @@ Cards.helpers({ return null; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else if (board && board.poker) { @@ -1699,7 +1699,7 @@ Cards.helpers({ return card.title; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1722,21 +1722,21 @@ Cards.helpers({ if (card === undefined) { return null; } - const board = Boards.findOne({ _id: card.boardId }); + const board = ReactiveCache.getBoard(card.boardId); if (board === undefined) { return null; } else { return board.title; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { return board.title; } } else { - const board = Boards.findOne({ _id: this.boardId }); + const board = ReactiveCache.getBoard(this.boardId); if (board === undefined) { return null; } else { @@ -1762,7 +1762,7 @@ Cards.helpers({ return card.archived; } } else if (this.isLinkedBoard()) { - const board = Boards.findOne({ _id: this.linkedId }); + const board = ReactiveCache.getBoard(this.linkedId); if (board === undefined) { return null; } else { @@ -1967,7 +1967,7 @@ Cards.mutations({ // This should never happen, but there was a bug that was fixed in commit // ea0239538a68e225c867411a4f3e0d27c158383. if (!swimlaneId) { - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); swimlaneId = board.getDefaultSwimline()._id; } // Move the minicard to the end of the target list @@ -1993,7 +1993,7 @@ Cards.mutations({ // This should never happen, but there was a bug that was fixed in commit // ea0239538a68e225c867411a4f3e0d27c158383. if (!swimlaneId) { - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); swimlaneId = board.getDefaultSwimline()._id; } listId = listId || this.listId; @@ -2016,7 +2016,7 @@ Cards.mutations({ // differs from the source board if (this.boardId !== boardId) { // Get label names - const oldBoard = Boards.findOne(this.boardId); + const oldBoard = ReactiveCache.getBoard(this.boardId); const oldBoardLabels = oldBoard.labels; const oldCardLabels = _.pluck( _.filter(oldBoardLabels, label => { @@ -2025,7 +2025,7 @@ Cards.mutations({ 'name', ); - const newBoard = Boards.findOne(boardId); + const newBoard = ReactiveCache.getBoard(boardId); const newBoardLabels = newBoard.labels; const newCardLabelIds = _.pluck( _.filter(newBoardLabels, label => { @@ -2683,10 +2683,10 @@ function cardMove( Activities.insert({ userId, activityType: 'moveCardBoard', - boardName: Boards.findOne(doc.boardId).title, + boardName: ReactiveCache.getBoard(doc.boardId).title, boardId: doc.boardId, oldBoardId, - oldBoardName: Boards.findOne(oldBoardId).title, + oldBoardName: ReactiveCache.getBoard(oldBoardId).title, cardId: doc._id, swimlaneName: Swimlanes.findOne(doc.swimlaneId).title, swimlaneId: doc.swimlaneId, @@ -3320,9 +3320,7 @@ if (Meteor.isServer) { Authentication.checkLoggedIn(req.userId); const paramBoardId = req.params.boardId; // Check user has permission to add card to the board - const board = Boards.findOne({ - _id: paramBoardId, - }); + const board = ReactiveCache.getBoard(paramBoardId); const addPermission = allowIsBoardMemberCommentOnly(req.userId, board); Authentication.checkAdminOrCondition(req.userId, addPermission); const paramListId = req.params.listId; diff --git a/models/checklists.js b/models/checklists.js index cab1855db..37a09ca89 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { DataCache } from 'meteor-reactive-cache' Checklists = new Mongo.Collection('checklists'); @@ -350,9 +351,7 @@ if (Meteor.isServer) { const paramBoardId = req.params.boardId; Authentication.checkBoardAccess(req.userId, paramBoardId); // Check user has permission to add checklist to the card - const board = Boards.findOne({ - _id: paramBoardId, - }); + const board = ReactiveCache.getBoard(paramBoardId); const addPermission = allowIsBoardMemberCommentOnly(req.userId, board); Authentication.checkAdminOrCondition(req.userId, addPermission); const paramCardId = req.params.cardId; diff --git a/models/csvCreator.js b/models/csvCreator.js index ed5e9112c..9899d7384 100644 --- a/models/csvCreator.js +++ b/models/csvCreator.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { isEmptyObject } from 'jquery'; import Boards from './boards'; @@ -320,7 +321,7 @@ export class CsvCreator { } // add the labels if (csvData[i][this.fieldIndex.labels]) { - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); for (const importedLabel of csvData[i][this.fieldIndex.labels].split( ' ', )) { @@ -387,7 +388,7 @@ export class CsvCreator { Meteor.settings.public && Meteor.settings.public.sandstorm; if (isSandstorm && currentBoardId) { - const currentBoard = Boards.findOne(currentBoardId); + const currentBoard = ReactiveCache.getBoard(currentBoardId); currentBoard.archive(); } this.mapHeadertoCardFieldIndex(board[0]); diff --git a/models/customFields.js b/models/customFields.js index 30c48f589..25337ed72 100644 --- a/models/customFields.js +++ b/models/customFields.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + CustomFields = new Mongo.Collection('customFields'); /** @@ -363,7 +365,7 @@ if (Meteor.isServer) { ) { const paramBoardId = req.params.boardId; Authentication.checkBoardAccess(req.userId, paramBoardId); - const board = Boards.findOne({ _id: paramBoardId }); + const board = ReactiveCache.getBoard(paramBoardId); const id = CustomFields.direct.insert({ name: req.body.name, type: req.body.type, diff --git a/models/exporter.js b/models/exporter.js index 273072b04..0997784ad 100644 --- a/models/exporter.js +++ b/models/exporter.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import moment from 'moment/min/moment-with-locales'; const Papa = require('papaparse'); import { TAPi18n } from '/imports/i18n'; @@ -34,7 +35,7 @@ export class Exporter { }; _.extend( result, - Boards.findOne(this._boardId, { + ReactiveCache.getBoard(this._boardId, { fields: { stars: 0, }, @@ -379,7 +380,7 @@ export class Exporter { } canExport(user) { - const board = Boards.findOne(this._boardId); + const board = ReactiveCache.getBoard(this._boardId); return board && board.isVisibleBy(user); } } diff --git a/models/integrations.js b/models/integrations.js index 704f66a3e..3da910b6b 100644 --- a/models/integrations.js +++ b/models/integrations.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + Integrations = new Mongo.Collection('integrations'); /** @@ -102,7 +104,7 @@ const permissionHelper = { allow(userId, doc) { const user = Users.findOne(userId); const isAdmin = user && Meteor.user().isAdmin; - return isAdmin || allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return isAdmin || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, }; Integrations.allow({ diff --git a/models/lists.js b/models/lists.js index 50f7a7803..9e924a05c 100644 --- a/models/lists.js +++ b/models/lists.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { ALLOWED_COLORS } from '/config/const'; Lists = new Mongo.Collection('lists'); @@ -175,13 +176,13 @@ Lists.attachSchema( Lists.allow({ insert(userId, doc) { - return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc) { - return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId)); }, fetch: ['boardId'], }); @@ -269,7 +270,7 @@ Lists.helpers({ }, board() { - return Boards.findOne(this.boardId); + return ReactiveCache.getBoard(this.boardId); }, getWipLimit(option) { @@ -559,7 +560,7 @@ if (Meteor.isServer) { try { const paramBoardId = req.params.boardId; Authentication.checkBoardAccess(req.userId, paramBoardId); - const board = Boards.findOne(paramBoardId); + const board = ReactiveCache.getBoard(paramBoardId); const id = Lists.insert({ title: req.body.title, boardId: paramBoardId, diff --git a/models/rules.js b/models/rules.js index b9d5b2a54..e3794c6fe 100644 --- a/models/rules.js +++ b/models/rules.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { Meteor } from 'meteor/meteor'; Rules = new Mongo.Collection('rules'); @@ -63,7 +64,7 @@ Rules.helpers({ return Triggers.findOne({ _id: this.triggerId }); }, board() { - return Boards.findOne({ _id: this.boardId }); + return ReactiveCache.getBoard(this.boardId); }, trigger() { return Triggers.findOne({ _id: this.triggerId }); @@ -75,13 +76,13 @@ Rules.helpers({ Rules.allow({ insert(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, }); diff --git a/models/swimlanes.js b/models/swimlanes.js index 9c3a7eea9..36308f90f 100644 --- a/models/swimlanes.js +++ b/models/swimlanes.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { ALLOWED_COLORS } from '/config/const'; Swimlanes = new Mongo.Collection('swimlanes'); @@ -111,13 +112,13 @@ Swimlanes.attachSchema( Swimlanes.allow({ insert(userId, doc) { - return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc) { - return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardMemberCommentOnly(userId, Boards.findOne(doc.boardId)); + return allowIsBoardMemberCommentOnly(userId, ReactiveCache.getBoard(doc.boardId)); }, fetch: ['boardId'], }); @@ -235,7 +236,7 @@ Swimlanes.helpers({ }, board() { - return Boards.findOne(this.boardId); + return ReactiveCache.getBoard(this.boardId); }, colorClass() { @@ -469,7 +470,7 @@ if (Meteor.isServer) { const paramBoardId = req.params.boardId; Authentication.checkBoardAccess(req.userId, paramBoardId); - const board = Boards.findOne(paramBoardId); + const board = ReactiveCache.getBoard(paramBoardId); const id = Swimlanes.insert({ title: req.body.title, boardId: paramBoardId, @@ -504,7 +505,7 @@ if (Meteor.isServer) { const paramBoardId = req.params.boardId; const paramSwimlaneId = req.params.swimlaneId; Authentication.checkBoardAccess(req.userId, paramBoardId); - const board = Boards.findOne(paramBoardId); + const board = ReactiveCache.getBoard(paramBoardId); const swimlane = Swimlanes.findOne({ _id: paramSwimlaneId, boardId: paramBoardId, diff --git a/models/trelloCreator.js b/models/trelloCreator.js index c34fdb6f0..e0efa3aac 100644 --- a/models/trelloCreator.js +++ b/models/trelloCreator.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import moment from 'moment/min/moment-with-locales'; import { TAPi18n } from '/imports/i18n'; @@ -753,7 +754,7 @@ export class TrelloCreator { Meteor.settings.public && Meteor.settings.public.sandstorm; if (isSandstorm && currentBoardId) { - const currentBoard = Boards.findOne(currentBoardId); + const currentBoard = ReactiveCache.getBoard(currentBoardId); currentBoard.archive(); } this.parseActions(board.actions); diff --git a/models/triggers.js b/models/triggers.js index 3314fd2d7..a4c376d40 100644 --- a/models/triggers.js +++ b/models/triggers.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { Meteor } from 'meteor/meteor'; Triggers = new Mongo.Collection('triggers'); @@ -24,13 +25,13 @@ Triggers.before.update((userId, doc, fieldNames, modifier) => { Triggers.allow({ insert(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, update(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, remove(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + return allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId)); }, }); diff --git a/models/users.js b/models/users.js index e3af94886..e9005cede 100644 --- a/models/users.js +++ b/models/users.js @@ -621,7 +621,7 @@ if (Meteor.isClient) { isBoardAdmin(boardId) { let board; if (boardId) { - board = Boards.findOne(boardId); + board = ReactiveCache.getBoard(boardId); } else { board = Utils.getCurrentBoard(); } @@ -1388,7 +1388,7 @@ if (Meteor.isServer) { check(boardId, String); const inviter = Meteor.user(); - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); const allowInvite = inviter && board && @@ -1453,7 +1453,7 @@ if (Meteor.isServer) { //Check if there is a subtasks board if (board.subtasksDefaultBoardId) { - const subBoard = Boards.findOne(board.subtasksDefaultBoardId); + const subBoard = ReactiveCache.getBoard(board.subtasksDefaultBoardId); //If there is, also add user to that board if (subBoard) { subBoard.addMember(user._id); @@ -1989,7 +1989,7 @@ if (Meteor.isServer) { throw new Meteor.Error('error-invitation-code-not-exist'); } else { invitationCode.boardsToBeInvited.forEach((boardId) => { - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); board.addMember(doc._id); }); if (!doc.profile) { diff --git a/models/wekanCreator.js b/models/wekanCreator.js index b48af847c..000830310 100644 --- a/models/wekanCreator.js +++ b/models/wekanCreator.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import moment from 'moment/min/moment-with-locales'; const DateString = Match.Where(function(dateAsString) { @@ -907,7 +908,7 @@ export class WekanCreator { Meteor.settings.public && Meteor.settings.public.sandstorm; if (isSandstorm && currentBoardId) { - const currentBoard = Boards.findOne(currentBoardId); + const currentBoard = ReactiveCache.getBoard(currentBoardId); currentBoard.archive(); } this.parseActivities(board); diff --git a/sandstorm.js b/sandstorm.js index 1b9a908b1..29fb082f0 100644 --- a/sandstorm.js +++ b/sandstorm.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { Meteor } from 'meteor/meteor'; import { Picker } from 'meteor/communitypackages:picker'; @@ -215,7 +216,7 @@ if (isSandstorm && Meteor.isServer) { const comment = CardComments.findOne(doc.commentId); caption = { defaultText: comment.text }; const activeMembers = _.pluck( - Boards.findOne(sandstormBoard._id).activeMembers(), + ReactiveCache.getBoard(sandstormBoard._id).activeMembers(), 'userId', ); (comment.text.match(/\B@([\w.]*)/g) || []).forEach(username => { diff --git a/server/authentication.js b/server/authentication.js index df8a5980b..2824d6b2f 100644 --- a/server/authentication.js +++ b/server/authentication.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import Fiber from 'fibers'; Meteor.startup(() => { @@ -55,7 +56,7 @@ Meteor.startup(() => { Authentication.checkBoardAccess = function(userId, boardId) { Authentication.checkLoggedIn(userId); - const board = Boards.findOne({ _id: boardId }); + const board = ReactiveCache.getBoard(boardId); const normalAccess = board.permission === 'public' || board.members.some(e => e.userId === userId && e.isActive); diff --git a/server/notifications/outgoing.js b/server/notifications/outgoing.js index aa99ff937..e9e42d58a 100644 --- a/server/notifications/outgoing.js +++ b/server/notifications/outgoing.js @@ -1,3 +1,4 @@ +import { ReactiveCache } from '/imports/reactiveCache'; import { TAPi18n } from '/imports/i18n'; if (Meteor.isServer) { @@ -79,7 +80,7 @@ if (Meteor.isServer) { cardId: paramCardId, boardId: paramBoardId, }); - const board = Boards.findOne(paramBoardId); + const board = ReactiveCache.getBoard(paramBoardId); const card = Cards.findOne(paramCardId); if (board && card) { if (comment) { diff --git a/server/notifications/watch.js b/server/notifications/watch.js index 8a628dade..0caa8d864 100644 --- a/server/notifications/watch.js +++ b/server/notifications/watch.js @@ -1,3 +1,5 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + Meteor.methods({ watch(watchableType, id, level) { check(watchableType, String); @@ -9,7 +11,7 @@ Meteor.methods({ let watchableObj = null; let board = null; if (watchableType === 'board') { - watchableObj = Boards.findOne(id); + watchableObj = ReactiveCache.getBoard(id); if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist'); board = watchableObj; } else if (watchableType === 'list') { diff --git a/server/publications/boards.js b/server/publications/boards.js index f95730624..bd8790fbc 100644 --- a/server/publications/boards.js +++ b/server/publications/boards.js @@ -2,6 +2,7 @@ // non-archived boards: // 1. that the user is a member of // 2. the user has starred +import { ReactiveCache } from '/imports/reactiveCache'; import Users from "../../models/users"; import Org from "../../models/org"; import Team from "../../models/team"; @@ -326,7 +327,7 @@ Meteor.methods({ check(boardId, String); check(properties, Object); - const board = Boards.findOne(boardId); + const board = ReactiveCache.getBoard(boardId); if (board) { for (const key in properties) { board[key] = properties[key]; diff --git a/server/publications/swimlanes.js b/server/publications/swimlanes.js index 4c119866a..b3f72fa0e 100644 --- a/server/publications/swimlanes.js +++ b/server/publications/swimlanes.js @@ -1,10 +1,12 @@ +import { ReactiveCache } from '/imports/reactiveCache'; + Meteor.methods({ copySwimlane(swimlaneId, toBoardId) { check(swimlaneId, String); check(toBoardId, String); const swimlane = Swimlanes.findOne(swimlaneId); - const toBoard = Boards.findOne(toBoardId); + const toBoard = ReactiveCache.getBoard(toBoardId); if (swimlane && toBoard) { swimlane.copy(toBoardId); @@ -19,7 +21,7 @@ Meteor.methods({ check(toBoardId, String); const swimlane = Swimlanes.findOne(swimlaneId); - const toBoard = Boards.findOne(toBoardId); + const toBoard = ReactiveCache.getBoard(toBoardId); if (swimlane && toBoard) { swimlane.move(toBoardId);