mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Move every CardComments.findOne() to the ReactiveCache
This commit is contained in:
parent
0e714a90e0
commit
0a7ffe4cb0
4 changed files with 27 additions and 4 deletions
|
@ -286,7 +286,7 @@ Template.commentReactions.events({
|
|||
if (ReactiveCache.getCurrentUser().isBoardMember()) {
|
||||
const codepoint = event.currentTarget.dataset['codepoint'];
|
||||
const commentId = Template.instance().data.commentId;
|
||||
const cardComment = CardComments.findOne({_id: commentId});
|
||||
const cardComment = ReactiveCache.getCardComment(commentId);
|
||||
cardComment.toggleReaction(codepoint);
|
||||
}
|
||||
},
|
||||
|
@ -298,7 +298,7 @@ Template.addReactionPopup.events({
|
|||
if (ReactiveCache.getCurrentUser().isBoardMember()) {
|
||||
const codepoint = event.currentTarget.dataset['codepoint'];
|
||||
const commentId = Template.instance().data.commentId;
|
||||
const cardComment = CardComments.findOne({_id: commentId});
|
||||
const cardComment = ReactiveCache.getCardComment(commentId);
|
||||
cardComment.toggleReaction(codepoint);
|
||||
}
|
||||
Popup.back();
|
||||
|
|
|
@ -27,6 +27,10 @@ ReactiveCacheServer = {
|
|||
const ret = Cards.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getCardComment(id) {
|
||||
const ret = CardComments.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getCustomField(id) {
|
||||
const ret = CustomFields.findOne(id);
|
||||
return ret;
|
||||
|
@ -113,6 +117,16 @@ ReactiveCacheClient = {
|
|||
const ret = this.__card.get(id);
|
||||
return ret;
|
||||
},
|
||||
getCardComment(id) {
|
||||
if (!this.__cardComment) {
|
||||
this.__cardComment = new DataCache(_id => {
|
||||
const _ret = CardComments.findOne(_id);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__cardComment.get(id);
|
||||
return ret;
|
||||
},
|
||||
getCustomField(id) {
|
||||
if (!this.__customField) {
|
||||
this.__customField = new DataCache(customFieldId => {
|
||||
|
@ -226,6 +240,15 @@ ReactiveCache = {
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
getCardComment(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getCardComment(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getCardComment(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCustomField(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
|
|
|
@ -41,7 +41,7 @@ Activities.helpers({
|
|||
return ReactiveCache.getCard(this.cardId);
|
||||
},
|
||||
comment() {
|
||||
return CardComments.findOne(this.commentId);
|
||||
return ReactiveCache.getCardComment(this.commentId);
|
||||
},
|
||||
attachment() {
|
||||
return Attachments.findOne(this.attachmentId);
|
||||
|
|
|
@ -213,7 +213,7 @@ if (isSandstorm && Meteor.isServer) {
|
|||
}
|
||||
|
||||
if (doc.activityType === 'addComment') {
|
||||
const comment = CardComments.findOne(doc.commentId);
|
||||
const comment = ReactiveCache.getCardComment(doc.commentId);
|
||||
caption = { defaultText: comment.text };
|
||||
const activeMembers = _.pluck(
|
||||
ReactiveCache.getBoard(sandstormBoard._id).activeMembers(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue