mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 18:30:13 +01: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({
|
BlazeComponent.extendComponent({
|
||||||
checkItem() {
|
checkItem() {
|
||||||
const checkItemId = this.currentData().activity.checklistItemId;
|
const checkItemId = this.currentData().activity.checklistItemId;
|
||||||
const checkItem = ChecklistItems.findOne({ _id: checkItemId });
|
const checkItem = ReactiveCache.getChecklistItem(checkItemId);
|
||||||
return checkItem && checkItem.title;
|
return checkItem && checkItem.title;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ ReactiveCacheServer = {
|
||||||
const ret = Checklists.findOne(id);
|
const ret = Checklists.findOne(id);
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getChecklistItem(id) {
|
||||||
|
const ret = ChecklistItems.findOne(id);
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCard(id) {
|
getCard(id) {
|
||||||
const ret = Cards.findOne(id);
|
const ret = Cards.findOne(id);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -89,6 +93,16 @@ ReactiveCacheClient = {
|
||||||
const ret = this.__checklist.get(id);
|
const ret = this.__checklist.get(id);
|
||||||
return ret;
|
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) {
|
getCard(id) {
|
||||||
if (!this.__card) {
|
if (!this.__card) {
|
||||||
this.__card = new DataCache(cardId => {
|
this.__card = new DataCache(cardId => {
|
||||||
|
|
@ -194,6 +208,15 @@ ReactiveCache = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getChecklistItem(id) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getChecklistItem(id);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getChecklistItem(id);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCard(id) {
|
getCard(id) {
|
||||||
let ret;
|
let ret;
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ Activities.helpers({
|
||||||
return Checklists.findOne(this.checklistId);
|
return Checklists.findOne(this.checklistId);
|
||||||
},
|
},
|
||||||
checklistItem() {
|
checklistItem() {
|
||||||
return ChecklistItems.findOne(this.checklistItemId);
|
return ReactiveCache.getChecklistItem(this.checklistItemId);
|
||||||
},
|
},
|
||||||
subtasks() {
|
subtasks() {
|
||||||
return ReactiveCache.getCard(this.subtaskId);
|
return ReactiveCache.getCard(this.subtaskId);
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ if (Meteor.isServer) {
|
||||||
const paramBoardId = req.params.boardId;
|
const paramBoardId = req.params.boardId;
|
||||||
const paramItemId = req.params.itemId;
|
const paramItemId = req.params.itemId;
|
||||||
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||||
const checklistItem = ChecklistItems.findOne({ _id: paramItemId });
|
const checklistItem = ReactiveCache.getChecklistItem(paramItemId);
|
||||||
if (checklistItem) {
|
if (checklistItem) {
|
||||||
JsonRoutes.sendResult(res, {
|
JsonRoutes.sendResult(res, {
|
||||||
code: 200,
|
code: 200,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue