Move every Cards.findOne() to the ReactiveCache

This commit is contained in:
Martin Filser 2022-12-16 16:36:47 +01:00
parent a182482cfb
commit 3b65113d05
24 changed files with 96 additions and 87 deletions

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
const commentFormIsOpen = new ReactiveVar(false); const commentFormIsOpen = new ReactiveVar(false);
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
@ -24,7 +26,7 @@ BlazeComponent.extendComponent({
let boardId = card.boardId; let boardId = card.boardId;
let cardId = card._id; let cardId = card._id;
if (card.isLinkedCard()) { if (card.isLinkedCard()) {
boardId = Cards.findOne(card.linkedId).boardId; boardId = ReactiveCache.getCard(card.linkedId).boardId;
cardId = card.linkedId; cardId = card.linkedId;
} else if (card.isLinkedBoard()) { } else if (card.isLinkedBoard()) {
boardId = card.linkedId; boardId = card.linkedId;

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
const subManager = new SubsManager(); const subManager = new SubsManager();
@ -388,7 +389,7 @@ BlazeComponent.extendComponent({
}, },
eventResize(event, delta, revertFunc) { eventResize(event, delta, revertFunc) {
let isOk = false; let isOk = false;
const card = Cards.findOne(event.id); const card = ReactiveCache.getCard(event.id);
if (card) { if (card) {
card.setEnd(event.end.toDate()); card.setEnd(event.end.toDate());
@ -400,7 +401,7 @@ BlazeComponent.extendComponent({
}, },
eventDrop(event, delta, revertFunc) { eventDrop(event, delta, revertFunc) {
let isOk = false; let isOk = false;
const card = Cards.findOne(event.id); const card = ReactiveCache.getCard(event.id);
if (card) { if (card) {
// TODO: add a flag for allDay events // TODO: add a flag for allDay events
if (!event.allDay) { if (!event.allDay) {

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { ObjectID } from 'bson'; import { ObjectID } from 'bson';
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
@ -322,7 +323,7 @@ Template.previewClipboardImagePopup.events({
BlazeComponent.extendComponent({ BlazeComponent.extendComponent({
isCover() { isCover() {
const ret = Cards.findOne(this.data().meta.cardId).coverId == this.data()._id; const ret = ReactiveCache.getCard(this.data().meta.cardId).coverId == this.data()._id;
return ret; return ret;
}, },
isBackgroundImage() { isBackgroundImage() {
@ -334,11 +335,11 @@ BlazeComponent.extendComponent({
return [ return [
{ {
'click .js-add-cover'() { 'click .js-add-cover'() {
Cards.findOne(this.data().meta.cardId).setCover(this.data()._id); ReactiveCache.getCard(this.data().meta.cardId).setCover(this.data()._id);
Popup.back(); Popup.back();
}, },
'click .js-remove-cover'() { 'click .js-remove-cover'() {
Cards.findOne(this.data().meta.cardId).unsetCover(); ReactiveCache.getCard(this.data().meta.cardId).unsetCover();
Popup.back(); Popup.back();
}, },
'click .js-add-background-image'() { 'click .js-add-background-image'() {

View file

@ -873,7 +873,7 @@ Template.editCardAssignerForm.events({
swimlaneId: swimlaneId, swimlaneId: swimlaneId,
sort: 0, sort: 0,
}); });
const card = Cards.findOne(_id); const card = ReactiveCache.getCard(_id);
const minOrder = card.getMinSort(); const minOrder = card.getMinSort();
card.move(card.boardId, card.swimlaneId, card.listId, minOrder - 1); card.move(card.boardId, card.swimlaneId, card.listId, minOrder - 1);
@ -1005,7 +1005,7 @@ BlazeComponent.extendComponent({
setParentCardId(cardId) { setParentCardId(cardId) {
if (cardId) { if (cardId) {
this.parentCard = Cards.findOne(cardId); this.parentCard = ReactiveCache.getCard(cardId);
} else { } else {
this.parentCard = null; this.parentCard = null;
} }
@ -1684,7 +1684,7 @@ Template.cardAssigneePopup.helpers({
Template.cardAssigneePopup.events({ Template.cardAssigneePopup.events({
'click .js-remove-assignee'() { 'click .js-remove-assignee'() {
Cards.findOne(this.cardId).unassignAssignee(this.userId); ReactiveCache.getCard(this.cardId).unassignAssignee(this.userId);
Popup.back(); Popup.back();
}, },
'click .js-edit-profile': Popup.open('editProfile'), 'click .js-edit-profile': Popup.open('editProfile'),

View file

@ -85,9 +85,11 @@ BlazeComponent.extendComponent({
const textarea = this.find('textarea.js-add-checklist-item'); const textarea = this.find('textarea.js-add-checklist-item');
const title = textarea.value.trim(); const title = textarea.value.trim();
let cardId = this.currentData().cardId; let cardId = this.currentData().cardId;
const card = Cards.findOne(cardId); const card = ReactiveCache.getCard(cardId);
//if (card.isLinked()) cardId = card.linkedId; //if (card.isLinked()) cardId = card.linkedId;
if (card.isLinkedCard()) cardId = card.linkedId; if (card.isLinkedCard()) {
cardId = card.linkedId;
}
let sortIndex; let sortIndex;
let checklistItemIndex; let checklistItemIndex;
@ -267,7 +269,7 @@ BlazeComponent.extendComponent({
Template.checklists.helpers({ Template.checklists.helpers({
checklists() { checklists() {
const card = Cards.findOne(this.cardId); const card = ReactiveCache.getCard(this.cardId);
const ret = card.checklists(); const ret = card.checklists();
return ret; return ret;
}, },

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
let labelColors; let labelColors;
Meteor.startup(() => { Meteor.startup(() => {
labelColors = Boards.simpleSchema()._schema['labels.$.color'].allowedValues; labelColors = Boards.simpleSchema()._schema['labels.$.color'].allowedValues;
@ -149,6 +151,6 @@ Template.editLabelPopup.events({
Template.cardLabelsPopup.helpers({ Template.cardLabelsPopup.helpers({
isLabelSelected(cardId) { isLabelSelected(cardId) {
return _.contains(Cards.findOne(cardId).labelIds, this._id); return _.contains(ReactiveCache.getCard(cardId).labelIds, this._id);
}, },
}); });

View file

@ -6,7 +6,7 @@ BlazeComponent.extendComponent({
const textarea = this.find('textarea.js-add-subtask-item'); const textarea = this.find('textarea.js-add-subtask-item');
const title = textarea.value.trim(); const title = textarea.value.trim();
const cardId = this.currentData().cardId; const cardId = this.currentData().cardId;
const card = Cards.findOne(cardId); const card = ReactiveCache.getCard(cardId);
const sortIndex = -1; const sortIndex = -1;
const crtBoard = ReactiveCache.getBoard(card.boardId); const crtBoard = ReactiveCache.getBoard(card.boardId);
const targetBoard = crtBoard.getDefaultSubtasksBoard(); const targetBoard = crtBoard.getDefaultSubtasksBoard();

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
require('/client/lib/jquery-ui.js') require('/client/lib/jquery-ui.js')
@ -188,7 +189,7 @@ BlazeComponent.extendComponent({
accept: '.js-member,.js-label', accept: '.js-member,.js-label',
drop(event, ui) { drop(event, ui) {
const cardId = Blaze.getData(this)._id; const cardId = Blaze.getData(this)._id;
const card = Cards.findOne(cardId); const card = ReactiveCache.getCard(cardId);
if (ui.draggable.hasClass('js-member')) { if (ui.draggable.hasClass('js-member')) {
const memberId = Blaze.getData(ui.draggable.get(0)).userId; const memberId = Blaze.getData(ui.draggable.get(0)).userId;

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import Cards from '/models/cards'; import Cards from '/models/cards';
import Avatars from '/models/avatars'; import Avatars from '/models/avatars';
import Users from '/models/users'; import Users from '/models/users';
@ -269,7 +270,7 @@ Template.cardMemberPopup.helpers({
Template.cardMemberPopup.events({ Template.cardMemberPopup.events({
'click .js-remove-member'() { 'click .js-remove-member'() {
Cards.findOne(this.cardId).unassignMember(this.userId); ReactiveCache.getCard(this.cardId).unassignMember(this.userId);
Popup.back(); Popup.back();
}, },
'click .js-edit-profile': Popup.open('editProfile'), 'click .js-edit-profile': Popup.open('editProfile'),

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n'; import { TAPi18n } from '/imports/i18n';
import Cards from '../../models/cards'; import Cards from '../../models/cards';
import SessionData from '../../models/usersessiondata'; import SessionData from '../../models/usersessiondata';
@ -74,7 +75,7 @@ export class CardSearchPagedComponent extends BlazeComponent {
console.log('session data:', this.sessionData); console.log('session data:', this.sessionData);
const cards = []; const cards = [];
this.sessionData.cards.forEach(cardId => { this.sessionData.cards.forEach(cardId => {
cards.push(Cards.findOne({ _id: cardId })); cards.push(ReactiveCache.getCard(cardId));
}); });
this.queryErrors = this.sessionData.errors; this.queryErrors = this.sessionData.errors;
if (this.queryErrors.length) { if (this.queryErrors.length) {

View file

@ -85,7 +85,7 @@ Mousetrap.bind(numbArray, (evt, key) => {
const cardIds = MultiSelection.getSelectedCardIds(); const cardIds = MultiSelection.getSelectedCardIds();
for (const cardId of cardIds) for (const cardId of cardIds)
{ {
card = Cards.findOne(cardId); card = ReactiveCache.getCard(cardId);
if(num <= board.labels.length) if(num <= board.labels.length)
{ {
card.removeLabel(labels[num-1]["_id"]); card.removeLabel(labels[num-1]["_id"]);
@ -109,7 +109,7 @@ Mousetrap.bind(numArray, (evt, key) => {
const cardIds = MultiSelection.getSelectedCardIds(); const cardIds = MultiSelection.getSelectedCardIds();
for (const cardId of cardIds) for (const cardId of cardIds)
{ {
card = Cards.findOne(cardId); card = ReactiveCache.getCard(cardId);
if(num <= board.labels.length) if(num <= board.labels.length)
{ {
card.addLabel(labels[num-1]["_id"]); card.addLabel(labels[num-1]["_id"]);
@ -123,7 +123,7 @@ Mousetrap.bind(numArray, (evt, key) => {
return; return;
} }
if (Meteor.user().isBoardMember()) { if (Meteor.user().isBoardMember()) {
const card = Cards.findOne(cardId); const card = ReactiveCache.getCard(cardId);
if(num <= board.labels.length) if(num <= board.labels.length)
{ {
card.toggleLabel(labels[num-1]["_id"]); card.toggleLabel(labels[num-1]["_id"]);
@ -143,7 +143,7 @@ Mousetrap.bind('space', evt => {
} }
if (Meteor.user().isBoardMember()) { if (Meteor.user().isBoardMember()) {
const card = Cards.findOne(cardId); const card = ReactiveCache.getCard(cardId);
card.toggleMember(currentUserId); card.toggleMember(currentUserId);
// We should prevent scrolling in card when spacebar is clicked // We should prevent scrolling in card when spacebar is clicked
// This should do it according to Mousetrap docs, but it doesn't // This should do it according to Mousetrap docs, but it doesn't
@ -167,7 +167,7 @@ Mousetrap.bind('c', evt => {
!Meteor.user().isCommentOnly() && !Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker() !Meteor.user().isWorker()
) { ) {
const card = Cards.findOne(cardId); const card = ReactiveCache.getCard(cardId);
card.archive(); card.archive();
// We should prevent scrolling in card when spacebar is clicked // We should prevent scrolling in card when spacebar is clicked
// This should do it according to Mousetrap docs, but it doesn't // This should do it according to Mousetrap docs, but it doesn't

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
function getCardsBetween(idA, idB) { function getCardsBetween(idA, idB) {
function pluckId(doc) { function pluckId(doc) {
return doc._id; return doc._id;
@ -13,7 +15,7 @@ function getCardsBetween(idA, idB) {
}).map(pluckId); }).map(pluckId);
} }
const cards = _.sortBy([Cards.findOne(idA), Cards.findOne(idB)], c => { const cards = _.sortBy([ReactiveCache.getCard(idA), ReactiveCache.getCard(idB)], c => {
return c.sort; return c.sort;
}); });

View file

@ -212,7 +212,7 @@ Utils = {
}, },
goCardId(_id) { goCardId(_id) {
const card = Cards.findOne(_id); const card = ReactiveCache.getCard(_id);
const board = ReactiveCache.getBoard(card.boardId); const board = ReactiveCache.getBoard(card.boardId);
return ( return (
board && board &&
@ -226,7 +226,7 @@ Utils = {
getCommonAttachmentMetaFrom(card) { getCommonAttachmentMetaFrom(card) {
const meta = {}; const meta = {};
if (card.isLinkedCard()) { if (card.isLinkedCard()) {
meta.boardId = Cards.findOne(card.linkedId).boardId; meta.boardId = ReactiveCache.getCard(card.linkedId).boardId;
meta.cardId = card.linkedId; meta.cardId = card.linkedId;
} else { } else {
meta.boardId = card.boardId; meta.boardId = card.boardId;

View file

@ -38,7 +38,7 @@ Activities.helpers({
return Lists.findOne(this.oldListId); return Lists.findOne(this.oldListId);
}, },
card() { card() {
return Cards.findOne(this.cardId); return ReactiveCache.getCard(this.cardId);
}, },
comment() { comment() {
return CardComments.findOne(this.commentId); return CardComments.findOne(this.commentId);
@ -53,14 +53,14 @@ Activities.helpers({
return ChecklistItems.findOne(this.checklistItemId); return ChecklistItems.findOne(this.checklistItemId);
}, },
subtasks() { subtasks() {
return Cards.findOne(this.subtaskId); return ReactiveCache.getCard(this.subtaskId);
}, },
customField() { customField() {
return CustomFields.findOne(this.customFieldId); return CustomFields.findOne(this.customFieldId);
}, },
// Label activity did not work yet, unable to edit labels when tried this. // Label activity did not work yet, unable to edit labels when tried this.
//label() { //label() {
// return Cards.findOne(this.labelId); // return ReactiveCache.getCard(this.labelId);
//}, //},
}); });

View file

@ -147,7 +147,7 @@ CardComments.helpers({
CardComments.hookOptions.after.update = { fetchPrevious: false }; CardComments.hookOptions.after.update = { fetchPrevious: false };
function commentCreation(userId, doc) { function commentCreation(userId, doc) {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
Activities.insert({ Activities.insert({
userId, userId,
activityType: 'addComment', activityType: 'addComment',
@ -194,7 +194,7 @@ if (Meteor.isServer) {
}); });
CardComments.after.update((userId, doc) => { CardComments.after.update((userId, doc) => {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
Activities.insert({ Activities.insert({
userId, userId,
activityType: 'editComment', activityType: 'editComment',
@ -207,7 +207,7 @@ if (Meteor.isServer) {
}); });
CardComments.before.remove((userId, doc) => { CardComments.before.remove((userId, doc) => {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
Activities.insert({ Activities.insert({
userId, userId,
activityType: 'deleteComment', activityType: 'deleteComment',

View file

@ -549,7 +549,7 @@ Cards.helpers({
copy(boardId, swimlaneId, listId) { copy(boardId, swimlaneId, listId) {
const oldId = this._id; const oldId = this._id;
const oldCard = Cards.findOne(oldId); const oldCard = ReactiveCache.getCard(oldId);
// we must only copy the labels and custom fields if the target board // we must only copy the labels and custom fields if the target board
// differs from the source board // differs from the source board
@ -1001,7 +1001,7 @@ Cards.helpers({
if (this.parentId === '') { if (this.parentId === '') {
return null; return null;
} }
return Cards.findOne(this.parentId); return ReactiveCache.getCard(this.parentId);
}, },
parentCardName() { parentCardName() {
@ -1019,7 +1019,7 @@ Cards.helpers({
const result = []; const result = [];
let crtParentId = this.parentId; let crtParentId = this.parentId;
while (crtParentId !== '') { while (crtParentId !== '') {
const crt = Cards.findOne(crtParentId); const crt = ReactiveCache.getCard(crtParentId);
if (crt === null || crt === undefined) { if (crt === null || crt === undefined) {
// maybe it has been deleted // maybe it has been deleted
break; break;
@ -1039,7 +1039,7 @@ Cards.helpers({
const result = []; const result = [];
let crtParentId = this.parentId; let crtParentId = this.parentId;
while (crtParentId !== '') { while (crtParentId !== '') {
const crt = Cards.findOne(crtParentId); const crt = ReactiveCache.getCard(crtParentId);
if (crt === null || crt === undefined) { if (crt === null || crt === undefined) {
// maybe it has been deleted // maybe it has been deleted
break; break;
@ -1089,7 +1089,7 @@ Cards.helpers({
getDescription() { getDescription() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card && card.description) return card.description; if (card && card.description) return card.description;
else return null; else return null;
} else if (this.isLinkedBoard()) { } else if (this.isLinkedBoard()) {
@ -1105,7 +1105,7 @@ Cards.helpers({
getMembers() { getMembers() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1127,7 +1127,7 @@ Cards.helpers({
getAssignees() { getAssignees() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1227,7 +1227,7 @@ Cards.helpers({
getReceived() { getReceived() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1255,7 +1255,7 @@ Cards.helpers({
getStart() { getStart() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1283,7 +1283,7 @@ Cards.helpers({
getDue() { getDue() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1311,7 +1311,7 @@ Cards.helpers({
getEnd() { getEnd() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1339,7 +1339,7 @@ Cards.helpers({
getIsOvertime() { getIsOvertime() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1367,7 +1367,7 @@ Cards.helpers({
getSpentTime() { getSpentTime() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1395,7 +1395,7 @@ Cards.helpers({
getVoteQuestion() { getVoteQuestion() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else if (card && card.vote) { } else if (card && card.vote) {
@ -1421,7 +1421,7 @@ Cards.helpers({
getVotePublic() { getVotePublic() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else if (card && card.vote) { } else if (card && card.vote) {
@ -1447,7 +1447,7 @@ Cards.helpers({
getVoteEnd() { getVoteEnd() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else if (card && card.vote) { } else if (card && card.vote) {
@ -1507,7 +1507,7 @@ Cards.helpers({
getPokerQuestion() { getPokerQuestion() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else if (card && card.poker) { } else if (card && card.poker) {
@ -1541,7 +1541,7 @@ Cards.helpers({
getPokerEnd() { getPokerEnd() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else if (card && card.poker) { } else if (card && card.poker) {
@ -1692,7 +1692,7 @@ Cards.helpers({
getTitle() { getTitle() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1718,7 +1718,7 @@ Cards.helpers({
getBoardTitle() { getBoardTitle() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} }
@ -1755,7 +1755,7 @@ Cards.helpers({
getArchived() { getArchived() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1779,7 +1779,7 @@ Cards.helpers({
getRequestedBy() { getRequestedBy() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -1796,7 +1796,7 @@ Cards.helpers({
getAssignedBy() { getAssignedBy() {
if (this.isLinkedCard()) { if (this.isLinkedCard()) {
const card = Cards.findOne({ _id: this.linkedId }); const card = ReactiveCache.getCard(this.linkedId);
if (card === undefined) { if (card === undefined) {
return null; return null;
} else { } else {
@ -3057,7 +3057,7 @@ if (Meteor.isServer) {
check(insertAtTop, Boolean); check(insertAtTop, Boolean);
check(mergeCardValues, Object); check(mergeCardValues, Object);
const card = Cards.findOne({_id: cardId}); const card = ReactiveCache.getCard(cardId);
Object.assign(card, mergeCardValues); Object.assign(card, mergeCardValues);
const sort = card.getSort(listId, swimlaneId, insertAtTop); const sort = card.getSort(listId, swimlaneId, insertAtTop);
@ -3140,7 +3140,7 @@ if (Meteor.isServer) {
const value = modifier.$set[action]; const value = modifier.$set[action];
const oldvalue = doc[action] || ''; const oldvalue = doc[action] || '';
const activityType = `a-${action}`; const activityType = `a-${action}`;
const card = Cards.findOne(doc._id); const card = ReactiveCache.getCard(doc._id);
const list = card.list(); const list = card.list();
if (list) { if (list) {
// change list modifiedAt, when user modified the key values in // change list modifiedAt, when user modified the key values in
@ -3370,9 +3370,7 @@ if (Meteor.isServer) {
}, },
}); });
const card = Cards.findOne({ const card = ReactiveCache.getCard(id);
_id: id,
});
cardCreation(req.body.authorId, card); cardCreation(req.body.authorId, card);
} else { } else {
JsonRoutes.sendResult(res, { JsonRoutes.sendResult(res, {
@ -3826,9 +3824,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function(
}, },
); );
const card = Cards.findOne({ const card = ReactiveCache.getCard(paramCardId);
_id: paramCardId,
});
cardMove( cardMove(
req.body.authorId, req.body.authorId,
card, card,
@ -3868,9 +3864,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function(
const paramCardId = req.params.cardId; const paramCardId = req.params.cardId;
Authentication.checkBoardAccess(req.userId, paramBoardId); Authentication.checkBoardAccess(req.userId, paramBoardId);
const card = Cards.findOne({ const card = ReactiveCache.getCard(paramCardId);
_id: paramCardId,
});
Cards.direct.remove({ Cards.direct.remove({
_id: paramCardId, _id: paramCardId,
listId: paramListId, listId: paramListId,

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
ChecklistItems = new Mongo.Collection('checklistItems'); ChecklistItems = new Mongo.Collection('checklistItems');
/** /**
@ -68,13 +70,13 @@ ChecklistItems.attachSchema(
ChecklistItems.allow({ ChecklistItems.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId)); return allowIsBoardMemberByCard(userId, ReactiveCache.getCard(doc.cardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId)); return allowIsBoardMemberByCard(userId, ReactiveCache.getCard(doc.cardId));
}, },
remove(userId, doc) { remove(userId, doc) {
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId)); return allowIsBoardMemberByCard(userId, ReactiveCache.getCard(doc.cardId));
}, },
fetch: ['userId', 'cardId'], fetch: ['userId', 'cardId'],
}); });
@ -113,7 +115,7 @@ ChecklistItems.mutations({
// Activities helper // Activities helper
function itemCreation(userId, doc) { function itemCreation(userId, doc) {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
const boardId = card.boardId; const boardId = card.boardId;
Activities.insert({ Activities.insert({
userId, userId,
@ -135,7 +137,7 @@ function itemRemover(userId, doc) {
} }
function publishCheckActivity(userId, doc) { function publishCheckActivity(userId, doc) {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
const boardId = card.boardId; const boardId = card.boardId;
let activityType; let activityType;
if (doc.isFinished) { if (doc.isFinished) {
@ -158,7 +160,7 @@ function publishCheckActivity(userId, doc) {
} }
function publishChekListCompleted(userId, doc) { function publishChekListCompleted(userId, doc) {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
const boardId = card.boardId; const boardId = card.boardId;
const checklistId = doc.checklistId; const checklistId = doc.checklistId;
const checkList = Checklists.findOne({ _id: checklistId }); const checkList = Checklists.findOne({ _id: checklistId });
@ -178,7 +180,7 @@ function publishChekListCompleted(userId, doc) {
} }
function publishChekListUncompleted(userId, doc) { function publishChekListUncompleted(userId, doc) {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
const boardId = card.boardId; const boardId = card.boardId;
const checklistId = doc.checklistId; const checklistId = doc.checklistId;
const checkList = Checklists.findOne({ _id: checklistId }); const checkList = Checklists.findOne({ _id: checklistId });
@ -233,7 +235,7 @@ if (Meteor.isServer) {
ChecklistItems.before.remove((userId, doc) => { ChecklistItems.before.remove((userId, doc) => {
itemRemover(userId, doc); itemRemover(userId, doc);
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
const boardId = card.boardId; const boardId = card.boardId;
Activities.insert({ Activities.insert({
userId, userId,

View file

@ -148,13 +148,13 @@ Checklists.helpers({
Checklists.allow({ Checklists.allow({
insert(userId, doc) { insert(userId, doc) {
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId)); return allowIsBoardMemberByCard(userId, ReactiveCache.getCard(doc.cardId));
}, },
update(userId, doc) { update(userId, doc) {
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId)); return allowIsBoardMemberByCard(userId, ReactiveCache.getCard(doc.cardId));
}, },
remove(userId, doc) { remove(userId, doc) {
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId)); return allowIsBoardMemberByCard(userId, ReactiveCache.getCard(doc.cardId));
}, },
fetch: ['userId', 'cardId'], fetch: ['userId', 'cardId'],
}); });
@ -210,7 +210,7 @@ if (Meteor.isServer) {
}); });
Checklists.after.insert((userId, doc) => { Checklists.after.insert((userId, doc) => {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
Activities.insert({ Activities.insert({
userId, userId,
activityType: 'addChecklist', activityType: 'addChecklist',
@ -225,7 +225,7 @@ if (Meteor.isServer) {
Checklists.before.remove((userId, doc) => { Checklists.before.remove((userId, doc) => {
const activities = Activities.find({ checklistId: doc._id }); const activities = Activities.find({ checklistId: doc._id });
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
if (activities) { if (activities) {
activities.forEach(activity => { activities.forEach(activity => {
Activities.remove(activity._id); Activities.remove(activity._id);
@ -235,7 +235,7 @@ if (Meteor.isServer) {
userId, userId,
activityType: 'removeChecklist', activityType: 'removeChecklist',
cardId: doc.cardId, cardId: doc.cardId,
boardId: Cards.findOne(doc.cardId).boardId, boardId: ReactiveCache.getCard(doc.cardId).boardId,
checklistId: doc._id, checklistId: doc._id,
checklistName: doc.title, checklistName: doc.title,
listId: card.listId, listId: card.listId,

View file

@ -218,7 +218,7 @@ function customFieldDeletion(userId, doc) {
// This has some bug, it does not show edited customField value at Outgoing Webhook, // This has some bug, it does not show edited customField value at Outgoing Webhook,
// instead it shows undefined, and no listId and swimlaneId. // instead it shows undefined, and no listId and swimlaneId.
function customFieldEdit(userId, doc) { function customFieldEdit(userId, doc) {
const card = Cards.findOne(doc.cardId); const card = ReactiveCache.getCard(doc.cardId);
const customFieldValue = Activities.findOne({ customFieldId: doc._id }).value; const customFieldValue = Activities.findOne({ customFieldId: doc._id }).value;
Activities.insert({ Activities.insert({
userId, userId,

View file

@ -613,7 +613,7 @@ export class WekanCreator {
: card.parentId; : card.parentId;
//if the parent card exists, proceed //if the parent card exists, proceed
if (Cards.findOne(parentIdInNewBoard)) { if (ReactiveCache.getCard(parentIdInNewBoard)) {
//set parent id of the card in the new board to the new id of the parent //set parent id of the card in the new board to the new id of the parent
Cards.direct.update(cardIdInNewBoard, { Cards.direct.update(cardIdInNewBoard, {
$set: { $set: {

View file

@ -205,7 +205,7 @@ if (isSandstorm && Meteor.isServer) {
if (doc.cardId) { if (doc.cardId) {
path = `b/sandstorm/libreboard/${doc.cardId}`; path = `b/sandstorm/libreboard/${doc.cardId}`;
Cards.findOne(doc.cardId).members.map(subscribedUser); ReactiveCache.getCard(doc.cardId).members.map(subscribedUser);
} }
if (doc.memberId) { if (doc.memberId) {

View file

@ -81,7 +81,7 @@ if (Meteor.isServer) {
boardId: paramBoardId, boardId: paramBoardId,
}); });
const board = ReactiveCache.getBoard(paramBoardId); const board = ReactiveCache.getBoard(paramBoardId);
const card = Cards.findOne(paramCardId); const card = ReactiveCache.getCard(paramCardId);
if (board && card) { if (board && card) {
if (comment) { if (comment) {
Lock.set(comment._id, newComment); Lock.set(comment._id, newComment);

View file

@ -19,7 +19,7 @@ Meteor.methods({
if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist'); if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist');
board = watchableObj.board(); board = watchableObj.board();
} else if (watchableType === 'card') { } else if (watchableType === 'card') {
watchableObj = Cards.findOne(id); watchableObj = ReactiveCache.getCard(id);
if (!watchableObj) throw new Meteor.Error('error-card-doesNotExist'); if (!watchableObj) throw new Meteor.Error('error-card-doesNotExist');
board = watchableObj.board(); board = watchableObj.board();
} else { } else {

View file

@ -1,4 +1,4 @@
//var nodemailer = require('nodemailer'); import { ReactiveCache } from '/imports/reactiveCache';
RulesHelper = { RulesHelper = {
executeRules(activity) { executeRules(activity) {
@ -58,7 +58,7 @@ RulesHelper = {
return matchingMap; return matchingMap;
}, },
performAction(activity, action) { performAction(activity, action) {
const card = Cards.findOne({ _id: activity.cardId }); const card = ReactiveCache.getCard(activity.cardId);
const boardId = activity.boardId; const boardId = activity.boardId;
if ( if (
action.actionType === 'moveCardToTop' || action.actionType === 'moveCardToTop' ||
@ -376,7 +376,7 @@ RulesHelper = {
} }
if (action.actionType === 'linkCard') { if (action.actionType === 'linkCard') {
const list = Lists.findOne({ title: action.listName, boardId: action.boardId }); const list = Lists.findOne({ title: action.listName, boardId: action.boardId });
const card = Cards.findOne({ _id: activity.cardId }); const card = ReactiveCache.getCard(activity.cardId);
let listId = ''; let listId = '';
let swimlaneId = ''; let swimlaneId = '';
const swimlane = Swimlanes.findOne({ const swimlane = Swimlanes.findOne({