Răsfoiți Sursa

Move every Lists.findOne(idOrFirstObjectSelector, options) to the ReactiveCache

Martin Filser 2 ani în urmă
părinte
comite
9e557f6887

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

@@ -251,7 +251,7 @@ BlazeComponent.extendComponent({
           if (lastList) {
             const positionInput = this.find('.list-position-input');
             const position = positionInput.value.trim();
-            const ret = Lists.findOne({ boardId: Utils.getCurrentBoardId(), _id: position, archived: false })
+            const ret = ReactiveCache.getList({ boardId: Utils.getCurrentBoardId(), _id: position, archived: false })
             sortIndex = parseInt(JSON.stringify(ret['sort']))
             sortIndex = sortIndex+1
           } else {

+ 1 - 1
client/lib/dialogWithBoardSwimlaneList.js

@@ -57,7 +57,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
     if (!this.selectedSwimlaneId.get() || !ReactiveCache.getSwimlane({_id: this.selectedSwimlaneId.get(), boardId: this.selectedBoardId.get()})) {
       this.setFirstSwimlaneId();
     }
-    if (!this.selectedListId.get() || !Lists.findOne({_id: this.selectedListId.get(), boardId: this.selectedBoardId.get()})) {
+    if (!this.selectedListId.get() || !ReactiveCache.getList({_id: this.selectedListId.get(), boardId: this.selectedBoardId.get()})) {
       this.setFirstListId();
     }
   }

+ 1 - 1
models/boards.js

@@ -763,7 +763,7 @@ Boards.helpers({
    * @returns Document the last list
    */
   getLastList() {
-    const ret = Lists.findOne({ boardId: this._id }, { sort: { sort: 'desc' } });
+    const ret = ReactiveCache.getList({ boardId: this._id }, { sort: { sort: 'desc' } });
     return ret;
   },
 

+ 3 - 3
models/lists.js

@@ -195,7 +195,7 @@ Lists.helpers({
     this.swimlaneId = swimlaneId;
 
     let _id = null;
-    const existingListWithSameName = Lists.findOne({
+    const existingListWithSameName = ReactiveCache.getList({
       boardId,
       title: this.title,
       archived: false,
@@ -219,7 +219,7 @@ Lists.helpers({
   },
 
   move(boardId, swimlaneId) {
-    const boardList = Lists.findOne({
+    const boardList = ReactiveCache.getList({
       boardId,
       title: this.title,
       archived: false,
@@ -534,7 +534,7 @@ if (Meteor.isServer) {
       Authentication.checkBoardAccess(req.userId, paramBoardId);
       JsonRoutes.sendResult(res, {
         code: 200,
-        data: Lists.findOne({
+        data: ReactiveCache.getList({
           _id: paramListId,
           boardId: paramBoardId,
           archived: false,

+ 1 - 1
models/swimlanes.js

@@ -150,7 +150,7 @@ Swimlanes.helpers({
 
   move(toBoardId) {
     this.lists().forEach(list => {
-      const toList = Lists.findOne({
+      const toList = ReactiveCache.getList({
         boardId: toBoardId,
         title: list.title,
         archived: false,

+ 1 - 1
models/triggers.js

@@ -55,7 +55,7 @@ Triggers.helpers({
   },
 
   findList(title) {
-    return Lists.findOne({
+    return ReactiveCache.getList({
       title,
     });
   },

+ 4 - 4
server/rulesHelper.js

@@ -69,10 +69,10 @@ RulesHelper = {
       if (action.listName === '*') {
         list = card.list();
         if (boardId !== action.boardId) {
-          list = Lists.findOne({ title: list.title, boardId: action.boardId });
+          list = ReactiveCache.getList({ title: list.title, boardId: action.boardId });
         }
       } else {
-        list = Lists.findOne({
+        list = ReactiveCache.getList({
           title: action.listName,
           boardId: action.boardId,
         });
@@ -349,7 +349,7 @@ RulesHelper = {
       }
     }
     if (action.actionType === 'createCard') {
-      const list = Lists.findOne({ title: action.listName, boardId });
+      const list = ReactiveCache.getList({ title: action.listName, boardId });
       let listId = '';
       let swimlaneId = '';
       const swimlane = ReactiveCache.getSwimlane({
@@ -375,7 +375,7 @@ RulesHelper = {
       });
     }
     if (action.actionType === 'linkCard') {
-      const list = Lists.findOne({ title: action.listName, boardId: action.boardId });
+      const list = ReactiveCache.getList({ title: action.listName, boardId: action.boardId });
       const card = ReactiveCache.getCard(activity.cardId);
       let listId = '';
       let swimlaneId = '';