mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Move every CardCommentReactions.findOne(idOrFirstObjectSelector, options) to the ReactiveCache
This commit is contained in:
parent
f5796faa84
commit
e30edce73e
2 changed files with 52 additions and 2 deletions
|
|
@ -59,6 +59,14 @@ ReactiveCacheServer = {
|
||||||
const ret = CardComments.find(selector, options).fetch();
|
const ret = CardComments.find(selector, options).fetch();
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getCardCommentReaction(idOrFirstObjectSelector, options) {
|
||||||
|
const ret = CardCommentReactions.findOne(idOrFirstObjectSelector, options);
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getCardCommentReactions(selector, options) {
|
||||||
|
const ret = CardCommentReactions.find(selector, options).fetch();
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCustomField(idOrFirstObjectSelector, options) {
|
getCustomField(idOrFirstObjectSelector, options) {
|
||||||
const ret = CustomFields.findOne(idOrFirstObjectSelector, options);
|
const ret = CustomFields.findOne(idOrFirstObjectSelector, options);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -313,6 +321,30 @@ ReactiveCacheClient = {
|
||||||
const ret = this.__cardComments.get(Jsons.stringify(select));
|
const ret = this.__cardComments.get(Jsons.stringify(select));
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getCardCommentReaction(idOrFirstObjectSelector, options) {
|
||||||
|
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||||
|
if (!this.__cardCommentReaction) {
|
||||||
|
this.__cardCommentReaction = new DataCache(_idOrFirstObjectSelect => {
|
||||||
|
const __select = Jsons.parse(_idOrFirstObjectSelect);
|
||||||
|
const _ret = CardCommentReactions.findOne(__select.idOrFirstObjectSelector, __select.options);
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ret = this.__cardCommentReaction.get(Jsons.stringify(idOrFirstObjectSelect));
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getCardCommentReactions(selector, options) {
|
||||||
|
const select = {selector, options}
|
||||||
|
if (!this.__cardCommentReactions) {
|
||||||
|
this.__cardCommentReactions = new DataCache(_select => {
|
||||||
|
const __select = Jsons.parse(_select);
|
||||||
|
const _ret = CardCommentReactions.find(__select.selector, __select.options).fetch();
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ret = this.__cardCommentReactions.get(Jsons.stringify(select));
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCustomField(idOrFirstObjectSelector, options) {
|
getCustomField(idOrFirstObjectSelector, options) {
|
||||||
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||||
if (!this.__customField) {
|
if (!this.__customField) {
|
||||||
|
|
@ -684,6 +716,24 @@ ReactiveCache = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getCardCommentReaction(idOrFirstObjectSelector, options) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getCardCommentReaction(idOrFirstObjectSelector, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getCardCommentReaction(idOrFirstObjectSelector, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getCardCommentReactions(selector, options) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getCardCommentReactions(selector, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getCardCommentReactions(selector, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCustomField(idOrFirstObjectSelector, options) {
|
getCustomField(idOrFirstObjectSelector, options) {
|
||||||
let ret;
|
let ret;
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ CardComments.helpers({
|
||||||
},
|
},
|
||||||
|
|
||||||
reactions() {
|
reactions() {
|
||||||
const cardCommentReactions = CardCommentReactions.findOne({cardCommentId: this._id});
|
const cardCommentReactions = ReactiveCache.getCardCommentReaction({cardCommentId: this._id});
|
||||||
return !!cardCommentReactions ? cardCommentReactions.reactions : [];
|
return !!cardCommentReactions ? cardCommentReactions.reactions : [];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -107,7 +107,7 @@ CardComments.helpers({
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const cardCommentReactions = CardCommentReactions.findOne({cardCommentId: this._id});
|
const cardCommentReactions = ReactiveCache.getCardCommentReaction({cardCommentId: this._id});
|
||||||
const reactions = !!cardCommentReactions ? cardCommentReactions.reactions : [];
|
const reactions = !!cardCommentReactions ? cardCommentReactions.reactions : [];
|
||||||
const userId = Meteor.userId();
|
const userId = Meteor.userId();
|
||||||
const reaction = reactions.find(r => r.reactionCodepoint === reactionCodepoint);
|
const reaction = reactions.find(r => r.reactionCodepoint === reactionCodepoint);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue