mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Move every ChecklistItems.findOne() to the ReactiveCache
This commit is contained in:
parent
5e3a9dc059
commit
0e714a90e0
4 changed files with 26 additions and 3 deletions
|
@ -66,7 +66,7 @@ Template.activities.helpers({
|
|||
BlazeComponent.extendComponent({
|
||||
checkItem() {
|
||||
const checkItemId = this.currentData().activity.checklistItemId;
|
||||
const checkItem = ChecklistItems.findOne({ _id: checkItemId });
|
||||
const checkItem = ReactiveCache.getChecklistItem(checkItemId);
|
||||
return checkItem && checkItem.title;
|
||||
},
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ ReactiveCacheServer = {
|
|||
const ret = Checklists.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getChecklistItem(id) {
|
||||
const ret = ChecklistItems.findOne(id);
|
||||
return ret;
|
||||
},
|
||||
getCard(id) {
|
||||
const ret = Cards.findOne(id);
|
||||
return ret;
|
||||
|
@ -89,6 +93,16 @@ ReactiveCacheClient = {
|
|||
const ret = this.__checklist.get(id);
|
||||
return ret;
|
||||
},
|
||||
getChecklistItem(id) {
|
||||
if (!this.__checklistItem) {
|
||||
this.__checklistItem = new DataCache(_id => {
|
||||
const _ret = ChecklistItems.findOne(_id);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__checklistItem.get(id);
|
||||
return ret;
|
||||
},
|
||||
getCard(id) {
|
||||
if (!this.__card) {
|
||||
this.__card = new DataCache(cardId => {
|
||||
|
@ -194,6 +208,15 @@ ReactiveCache = {
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
getChecklistItem(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getChecklistItem(id);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getChecklistItem(id);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCard(id) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
|
|
|
@ -50,7 +50,7 @@ Activities.helpers({
|
|||
return Checklists.findOne(this.checklistId);
|
||||
},
|
||||
checklistItem() {
|
||||
return ChecklistItems.findOne(this.checklistItemId);
|
||||
return ReactiveCache.getChecklistItem(this.checklistItemId);
|
||||
},
|
||||
subtasks() {
|
||||
return ReactiveCache.getCard(this.subtaskId);
|
||||
|
|
|
@ -270,7 +270,7 @@ if (Meteor.isServer) {
|
|||
const paramBoardId = req.params.boardId;
|
||||
const paramItemId = req.params.itemId;
|
||||
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||
const checklistItem = ChecklistItems.findOne({ _id: paramItemId });
|
||||
const checklistItem = ReactiveCache.getChecklistItem(paramItemId);
|
||||
if (checklistItem) {
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue