Ver Fonte

Move every Boards.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory client/)

Martin Filser há 2 anos atrás
pai
commit
10a9306abd

+ 2 - 1
client/components/boards/boardArchive.js

@@ -10,12 +10,13 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   archivedBoards() {
   archivedBoards() {
-    return Boards.find(
+    const ret = ReactiveCache.getBoards(
       { archived: true },
       { archived: true },
       {
       {
         sort: { archivedAt: -1, modifiedAt: -1 },
         sort: { archivedAt: -1, modifiedAt: -1 },
       },
       },
     );
     );
+    return ret;
   },
   },
 
 
   events() {
   events() {

+ 4 - 3
client/components/boards/boardsList.js

@@ -181,9 +181,10 @@ BlazeComponent.extendComponent({
       };
       };
     }
     }
 
 
-    return Boards.find(query, {
+    const ret = ReactiveCache.getBoards(query, {
       sort: { sort: 1 /* boards default sorting */ },
       sort: { sort: 1 /* boards default sorting */ },
     });
     });
+    return ret;
   },
   },
   boardLists(boardId) {
   boardLists(boardId) {
     let boardLists = [];
     let boardLists = [];
@@ -248,7 +249,7 @@ BlazeComponent.extendComponent({
             'copyBoard',
             'copyBoard',
             this.currentData()._id,
             this.currentData()._id,
             {
             {
-              sort: Boards.find({ archived: false }).count(),
+              sort: ReactiveCache.getBoards({ archived: false }).length,
               type: 'board',
               type: 'board',
               title: ReactiveCache.getBoard(this.currentData()._id).title,
               title: ReactiveCache.getBoard(this.currentData()._id).title,
             },
             },
@@ -324,7 +325,7 @@ BlazeComponent.extendComponent({
               query.$and[2].$or.push({ 'orgs.orgId': { $in: selectedOrgsValues } });
               query.$and[2].$or.push({ 'orgs.orgId': { $in: selectedOrgsValues } });
             }
             }
 
 
-            let filteredBoards = Boards.find(query, {}).fetch();
+            let filteredBoards = ReactiveCache.getBoards(query, {});
             let allBoards = document.getElementsByClassName("js-board");
             let allBoards = document.getElementsByClassName("js-board");
             let currBoard;
             let currBoard;
             if (filteredBoards.length > 0) {
             if (filteredBoards.length > 0) {

+ 3 - 4
client/components/cards/cardDetails.js

@@ -961,18 +961,17 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   boards() {
   boards() {
-    return Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),
-        _id: {
-          $ne: ReactiveCache.getCurrentUser().getTemplatesBoardId(),
-        },
+        _id: { $ne: ReactiveCache.getCurrentUser().getTemplatesBoardId() },
       },
       },
       {
       {
         sort: { sort: 1 /* boards default sorting */ },
         sort: { sort: 1 /* boards default sorting */ },
       },
       },
     );
     );
+    return ret;
   },
   },
 
 
   cards() {
   cards() {

+ 2 - 1
client/components/cards/checklists.js

@@ -233,7 +233,7 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   boards() {
   boards() {
-    return Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),
@@ -243,6 +243,7 @@ BlazeComponent.extendComponent({
         sort: { sort: 1 /* boards default sorting */ },
         sort: { sort: 1 /* boards default sorting */ },
       },
       },
     );
     );
+    return ret;
   },
   },
 
 
   swimlanes() {
   swimlanes() {

+ 5 - 5
client/components/lists/listBody.js

@@ -444,7 +444,7 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   boards() {
   boards() {
-    const boards = Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),
@@ -455,7 +455,7 @@ BlazeComponent.extendComponent({
         sort: { sort: 1 /* boards default sorting */ },
         sort: { sort: 1 /* boards default sorting */ },
       },
       },
     );
     );
-    return boards;
+    return ret;
   },
   },
 
 
   swimlanes() {
   swimlanes() {
@@ -650,7 +650,7 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   boards() {
   boards() {
-    const boards = Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),
@@ -661,7 +661,7 @@ BlazeComponent.extendComponent({
         sort: { sort: 1 /* boards default sorting */ },
         sort: { sort: 1 /* boards default sorting */ },
       },
       },
     );
     );
-    return boards;
+    return ret;
   },
   },
 
 
   results() {
   results() {
@@ -752,7 +752,7 @@ BlazeComponent.extendComponent({
               'copyBoard',
               'copyBoard',
               element.linkedId,
               element.linkedId,
               {
               {
-                sort: Boards.find({ archived: false }).count(),
+                sort: ReactiveCache.getBoards({ archived: false }).length,
                 type: 'board',
                 type: 'board',
                 title: element.title,
                 title: element.title,
               },
               },

+ 2 - 2
client/components/rules/actions/boardActions.js

@@ -4,7 +4,7 @@ BlazeComponent.extendComponent({
   onCreated() {},
   onCreated() {},
 
 
   boards() {
   boards() {
-    const boards = Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),
@@ -16,7 +16,7 @@ BlazeComponent.extendComponent({
         sort: { sort: 1 /* boards default sorting */ },
         sort: { sort: 1 /* boards default sorting */ },
       },
       },
     );
     );
-    return boards;
+    return ret;
   },
   },
 
 
   events() {
   events() {

+ 3 - 1
client/components/settings/settingBody.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { TAPi18n } from '/imports/i18n';
 import { TAPi18n } from '/imports/i18n';
 import { ALLOWED_WAIT_SPINNERS } from '/config/const';
 import { ALLOWED_WAIT_SPINNERS } from '/config/const';
 
 
@@ -43,7 +44,7 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   boards() {
   boards() {
-    return Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),
@@ -53,6 +54,7 @@ BlazeComponent.extendComponent({
         sort: { sort: 1 /* boards default sorting */ },
         sort: { sort: 1 /* boards default sorting */ },
       },
       },
     );
     );
+    return ret;
   },
   },
   toggleForgotPassword() {
   toggleForgotPassword() {
     this.setLoading(true);
     this.setLoading(true);

+ 4 - 2
client/components/sidebar/sidebar.js

@@ -786,7 +786,7 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   boards() {
   boards() {
-    return Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),
@@ -795,6 +795,7 @@ BlazeComponent.extendComponent({
         sort: { sort: 1 /* boards default sorting */ },
         sort: { sort: 1 /* boards default sorting */ },
       },
       },
     );
     );
+    return ret;
   },
   },
 
 
   lists() {
   lists() {
@@ -984,7 +985,7 @@ BlazeComponent.extendComponent({
   },
   },
 
 
   boards() {
   boards() {
-    return Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),
@@ -993,6 +994,7 @@ BlazeComponent.extendComponent({
         sort: { sort: 1 /* boards default sorting */ },
         sort: { sort: 1 /* boards default sorting */ },
       },
       },
     );
     );
+    return ret;
   },
   },
 
 
   lists() {
   lists() {

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

@@ -345,7 +345,8 @@ class MoveSwimlaneComponent extends BlazeComponent {
   }
   }
 
 
   toBoards() {
   toBoards() {
-    return Boards.find(this.toBoardsSelector(), { sort: { title: 1 } });
+    const ret = ReactiveCache.getBoards(this.toBoardsSelector(), { sort: { title: 1 } });
+    return ret;
   }
   }
 
 
   events() {
   events() {

+ 1 - 1
client/lib/dialogWithBoardSwimlaneList.js

@@ -107,7 +107,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
 
 
   /** returns all available board */
   /** returns all available board */
   boards() {
   boards() {
-    const ret = Boards.find(
+    const ret = ReactiveCache.getBoards(
       {
       {
         archived: false,
         archived: false,
         'members.userId': Meteor.userId(),
         'members.userId': Meteor.userId(),

+ 1 - 1
client/lib/utils.js

@@ -163,7 +163,7 @@ Utils = {
 
 
   archivedBoardIds() {
   archivedBoardIds() {
     const archivedBoards = [];
     const archivedBoards = [];
-    Boards.find({ archived: false }).forEach(board => {
+    ReactiveCache.getBoards({ archived: false }).forEach(board => {
       archivedBoards.push(board._id);
       archivedBoards.push(board._id);
     });
     });
     return archivedBoards;
     return archivedBoards;