Explorar o código

Move every Lists.findOne() to the ReactiveCache

Martin Filser %!s(int64=2) %!d(string=hai) anos
pai
achega
0926943670

+ 1 - 1
client/components/swimlanes/swimlanes.js

@@ -1,7 +1,7 @@
 const { calculateIndex } = Utils;
 const { calculateIndex } = Utils;
 
 
 function currentListIsInThisSwimlane(swimlaneId) {
 function currentListIsInThisSwimlane(swimlaneId) {
-  const currentList = Lists.findOne(Session.get('currentList'));
+  const currentList = Utils.getCurrentList();
   return (
   return (
     currentList &&
     currentList &&
     (currentList.swimlaneId === swimlaneId || currentList.swimlaneId === '')
     (currentList.swimlaneId === swimlaneId || currentList.swimlaneId === '')

+ 2 - 1
client/lib/dialogWithBoardSwimlaneListCard.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { DialogWithBoardSwimlaneList } from '/client/lib/dialogWithBoardSwimlaneList';
 import { DialogWithBoardSwimlaneList } from '/client/lib/dialogWithBoardSwimlaneList';
 
 
 export class DialogWithBoardSwimlaneListCard extends DialogWithBoardSwimlaneList {
 export class DialogWithBoardSwimlaneListCard extends DialogWithBoardSwimlaneList {
@@ -22,7 +23,7 @@ export class DialogWithBoardSwimlaneListCard extends DialogWithBoardSwimlaneList
 
 
   /** returns all available cards of the current list */
   /** returns all available cards of the current list */
   cards() {
   cards() {
-    const list = Lists.findOne(this.selectedListId.get());
+    const list = ReactiveCache.getList(this.selectedListId.get());
     let ret = [];
     let ret = [];
     if (list) {
     if (list) {
       ret = list.cards(this.selectedSwimlaneId.get());
       ret = list.cards(this.selectedSwimlaneId.get());

+ 2 - 2
client/lib/multiSelection.js

@@ -8,8 +8,8 @@ function getCardsBetween(idA, idB) {
   function getListsStrictlyBetween(id1, id2) {
   function getListsStrictlyBetween(id1, id2) {
     return Lists.find({
     return Lists.find({
       $and: [
       $and: [
-        { sort: { $gt: Lists.findOne(id1).sort } },
-        { sort: { $lt: Lists.findOne(id2).sort } },
+        { sort: { $gt: ReactiveCache.getList(id1).sort } },
+        { sort: { $lt: ReactiveCache.getList(id2).sort } },
       ],
       ],
       archived: false,
       archived: false,
     }).map(pluckId);
     }).map(pluckId);

+ 2 - 2
models/activities.js

@@ -26,7 +26,7 @@ Activities.helpers({
     return Users.findOne(this.memberId);
     return Users.findOne(this.memberId);
   },
   },
   list() {
   list() {
-    return Lists.findOne(this.listId);
+    return ReactiveCache.getList(this.listId);
   },
   },
   swimlane() {
   swimlane() {
     return Swimlanes.findOne(this.swimlaneId);
     return Swimlanes.findOne(this.swimlaneId);
@@ -35,7 +35,7 @@ Activities.helpers({
     return Swimlanes.findOne(this.oldSwimlaneId);
     return Swimlanes.findOne(this.oldSwimlaneId);
   },
   },
   oldList() {
   oldList() {
-    return Lists.findOne(this.oldListId);
+    return ReactiveCache.getList(this.oldListId);
   },
   },
   card() {
   card() {
     return ReactiveCache.getCard(this.cardId);
     return ReactiveCache.getCard(this.cardId);

+ 2 - 2
models/boards.js

@@ -1176,7 +1176,7 @@ Boards.helpers({
   },
   },
 
 
   getDefaultSubtasksList() {
   getDefaultSubtasksList() {
-    return Lists.findOne(this.getDefaultSubtasksListId());
+    return ReactiveCache.getList(this.getDefaultSubtasksListId());
   },
   },
 
 
   getDefaultDateSettingsListId() {
   getDefaultDateSettingsListId() {
@@ -1194,7 +1194,7 @@ Boards.helpers({
   },
   },
 
 
   getDefaultDateSettingsList() {
   getDefaultDateSettingsList() {
-    return Lists.findOne(this.getDefaultDateSettingsListId());
+    return ReactiveCache.getList(this.getDefaultDateSettingsListId());
   },
   },
 
 
   getDefaultSwimline() {
   getDefaultSwimline() {

+ 4 - 4
models/lists.js

@@ -274,7 +274,7 @@ Lists.helpers({
   },
   },
 
 
   getWipLimit(option) {
   getWipLimit(option) {
-    const list = Lists.findOne({ _id: this._id });
+    const list = ReactiveCache.getList(this._id);
     if (!list.wipLimit) {
     if (!list.wipLimit) {
       // Necessary check to avoid exceptions for the case where the doc doesn't have the wipLimit field yet set
       // Necessary check to avoid exceptions for the case where the doc doesn't have the wipLimit field yet set
       return 0;
       return 0;
@@ -389,12 +389,12 @@ Meteor.methods({
     if (limit === 0) {
     if (limit === 0) {
       limit = 1;
       limit = 1;
     }
     }
-    Lists.findOne({ _id: listId }).setWipLimit(limit);
+    ReactiveCache.getList(listId).setWipLimit(limit);
   },
   },
 
 
   enableWipLimit(listId) {
   enableWipLimit(listId) {
     check(listId, String);
     check(listId, String);
-    const list = Lists.findOne({ _id: listId });
+    const list = ReactiveCache.getList(listId);
     if (list.getWipLimit('value') === 0) {
     if (list.getWipLimit('value') === 0) {
       list.setWipLimit(1);
       list.setWipLimit(1);
     }
     }
@@ -403,7 +403,7 @@ Meteor.methods({
 
 
   enableSoftLimit(listId) {
   enableSoftLimit(listId) {
     check(listId, String);
     check(listId, String);
-    const list = Lists.findOne({ _id: listId });
+    const list = ReactiveCache.getList(listId);
     list.toggleSoftLimit(!list.getWipLimit('soft'));
     list.toggleSoftLimit(!list.getWipLimit('soft'));
   },
   },
 
 

+ 2 - 2
models/triggers.js

@@ -47,11 +47,11 @@ Triggers.helpers({
   },
   },
 
 
   fromList() {
   fromList() {
-    return Lists.findOne(this.fromId);
+    return ReactiveCache.getList(this.fromId);
   },
   },
 
 
   toList() {
   toList() {
-    return Lists.findOne(this.toId);
+    return ReactiveCache.getList(this.toId);
   },
   },
 
 
   findList(title) {
   findList(title) {

+ 1 - 1
server/notifications/watch.js

@@ -15,7 +15,7 @@ Meteor.methods({
       if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
       if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
       board = watchableObj;
       board = watchableObj;
     } else if (watchableType === 'list') {
     } else if (watchableType === 'list') {
-      watchableObj = Lists.findOne(id);
+      watchableObj = ReactiveCache.getList(id);
       if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist');
       if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist');
       board = watchableObj.board();
       board = watchableObj.board();
     } else if (watchableType === 'card') {
     } else if (watchableType === 'card') {

+ 1 - 1
server/rulesHelper.js

@@ -37,7 +37,7 @@ RulesHelper = {
       // in any [*] board
       // in any [*] board
       let value = activity[field];
       let value = activity[field];
       if (field === 'oldListName') {
       if (field === 'oldListName') {
-        const oldList = Lists.findOne({ _id: activity.oldListId });
+        const oldList = ReactiveCache.getList(activity.oldListId);
         if (oldList) {
         if (oldList) {
           value = oldList.title;
           value = oldList.title;
         }
         }