mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01: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()) {
|
if (ReactiveCache.getCurrentUser().isBoardMember()) {
|
||||||
const codepoint = event.currentTarget.dataset['codepoint'];
|
const codepoint = event.currentTarget.dataset['codepoint'];
|
||||||
const commentId = Template.instance().data.commentId;
|
const commentId = Template.instance().data.commentId;
|
||||||
const cardComment = CardComments.findOne({_id: commentId});
|
const cardComment = ReactiveCache.getCardComment(commentId);
|
||||||
cardComment.toggleReaction(codepoint);
|
cardComment.toggleReaction(codepoint);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -298,7 +298,7 @@ Template.addReactionPopup.events({
|
||||||
if (ReactiveCache.getCurrentUser().isBoardMember()) {
|
if (ReactiveCache.getCurrentUser().isBoardMember()) {
|
||||||
const codepoint = event.currentTarget.dataset['codepoint'];
|
const codepoint = event.currentTarget.dataset['codepoint'];
|
||||||
const commentId = Template.instance().data.commentId;
|
const commentId = Template.instance().data.commentId;
|
||||||
const cardComment = CardComments.findOne({_id: commentId});
|
const cardComment = ReactiveCache.getCardComment(commentId);
|
||||||
cardComment.toggleReaction(codepoint);
|
cardComment.toggleReaction(codepoint);
|
||||||
}
|
}
|
||||||
Popup.back();
|
Popup.back();
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ ReactiveCacheServer = {
|
||||||
const ret = Cards.findOne(id);
|
const ret = Cards.findOne(id);
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getCardComment(id) {
|
||||||
|
const ret = CardComments.findOne(id);
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCustomField(id) {
|
getCustomField(id) {
|
||||||
const ret = CustomFields.findOne(id);
|
const ret = CustomFields.findOne(id);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -113,6 +117,16 @@ ReactiveCacheClient = {
|
||||||
const ret = this.__card.get(id);
|
const ret = this.__card.get(id);
|
||||||
return ret;
|
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) {
|
getCustomField(id) {
|
||||||
if (!this.__customField) {
|
if (!this.__customField) {
|
||||||
this.__customField = new DataCache(customFieldId => {
|
this.__customField = new DataCache(customFieldId => {
|
||||||
|
|
@ -226,6 +240,15 @@ ReactiveCache = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getCardComment(id) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getCardComment(id);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getCardComment(id);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCustomField(id) {
|
getCustomField(id) {
|
||||||
let ret;
|
let ret;
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ Activities.helpers({
|
||||||
return ReactiveCache.getCard(this.cardId);
|
return ReactiveCache.getCard(this.cardId);
|
||||||
},
|
},
|
||||||
comment() {
|
comment() {
|
||||||
return CardComments.findOne(this.commentId);
|
return ReactiveCache.getCardComment(this.commentId);
|
||||||
},
|
},
|
||||||
attachment() {
|
attachment() {
|
||||||
return Attachments.findOne(this.attachmentId);
|
return Attachments.findOne(this.attachmentId);
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ if (isSandstorm && Meteor.isServer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc.activityType === 'addComment') {
|
if (doc.activityType === 'addComment') {
|
||||||
const comment = CardComments.findOne(doc.commentId);
|
const comment = ReactiveCache.getCardComment(doc.commentId);
|
||||||
caption = { defaultText: comment.text };
|
caption = { defaultText: comment.text };
|
||||||
const activeMembers = _.pluck(
|
const activeMembers = _.pluck(
|
||||||
ReactiveCache.getBoard(sandstormBoard._id).activeMembers(),
|
ReactiveCache.getBoard(sandstormBoard._id).activeMembers(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue