瀏覽代碼

Move every Swimlanes.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory models/)

Martin Filser 2 年之前
父節點
當前提交
33a8de7bb5

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

@@ -471,7 +471,7 @@ BlazeComponent.extendComponent({
       sort: { sort: 1 },
     });
     if (swimlanes.length)
-      this.selectedSwimlaneId.set(swimlanes.fetch()[0]._id);
+      this.selectedSwimlaneId.set(swimlanes[0]._id);
     return swimlanes;
   },
 

+ 4 - 4
models/boards.js

@@ -638,7 +638,7 @@ Boards.helpers({
     const _id = Boards.insert(this);
 
     // Copy all swimlanes in board
-    Swimlanes.find({
+    ReactiveCache.getSwimlanes({
       boardId: oldId,
       archived: false,
     }).forEach(swimlane => {
@@ -777,7 +777,7 @@ Boards.helpers({
   },
 
   swimlanes() {
-    return Swimlanes.find(
+    return ReactiveCache.getSwimlanes(
       { boardId: this._id, archived: false },
       { sort: { sort: 1 } },
     );
@@ -798,7 +798,7 @@ Boards.helpers({
   },
 
   nullSortSwimlanes() {
-    return Swimlanes.find({
+    return ReactiveCache.getSwimlanes({
       boardId: this._id,
       archived: false,
       sort: { $eq: null },
@@ -1031,7 +1031,7 @@ Boards.helpers({
       query.$or = [{ title: regex }, { description: regex }];
     }
 
-    return Swimlanes.find(query, projection);
+    return ReactiveCache.getSwimlanes(query, projection);
   },
 
   searchLists(term) {

+ 1 - 1
models/exporter.js

@@ -99,7 +99,7 @@ export class Exporter {
 
     result.lists = ReactiveCache.getLists(byBoard, noBoardId);
     result.cards = ReactiveCache.getCards(byBoardNoLinked, noBoardId);
-    result.swimlanes = Swimlanes.find(byBoard, noBoardId).fetch();
+    result.swimlanes = ReactiveCache.getSwimlanes(byBoard, noBoardId);
     result.customFields = CustomFields.find(
       { boardIds: this._boardId },
       { fields: { boardIds: 0 } },

+ 1 - 1
models/server/ExporterCardPDF.js

@@ -42,7 +42,7 @@ class ExporterCardPDF {
         );
         result.lists = ReactiveCache.getLists(byBoard, noBoardId);
         result.cards = ReactiveCache.getCards(byBoardNoLinked, noBoardId);
-        result.swimlanes = Swimlanes.find(byBoard, noBoardId).fetch();
+        result.swimlanes = ReactiveCache.getSwimlanes(byBoard, noBoardId);
         result.customFields = CustomFields.find(
           {
             boardIds: {

+ 1 - 1
models/server/ExporterExcel.js

@@ -44,7 +44,7 @@ class ExporterExcel {
     );
     result.lists = ReactiveCache.getLists(byBoard, noBoardId);
     result.cards = ReactiveCache.getCards(byBoardNoLinked, noBoardId);
-    result.swimlanes = Swimlanes.find(byBoard, noBoardId).fetch();
+    result.swimlanes = ReactiveCache.getSwimlanes(byBoard, noBoardId);
     result.customFields = CustomFields.find(
       {
         boardIds: {

+ 4 - 4
models/swimlanes.js

@@ -305,7 +305,7 @@ Swimlanes.mutations({
 });
 
 Swimlanes.userArchivedSwimlanes = userId => {
-  return Swimlanes.find({
+  return ReactiveCache.getSwimlanes({
     boardId: { $in: Boards.userBoardIds(userId, null) },
     archived: true,
   })
@@ -316,7 +316,7 @@ Swimlanes.userArchivedSwimlaneIds = () => {
 };
 
 Swimlanes.archivedSwimlanes = () => {
-  return Swimlanes.find({ archived: true });
+  return ReactiveCache.getSwimlanes({ archived: true });
 };
 
 Swimlanes.archivedSwimlaneIds = () => {
@@ -402,7 +402,7 @@ if (Meteor.isServer) {
 
       JsonRoutes.sendResult(res, {
         code: 200,
-        data: Swimlanes.find({ boardId: paramBoardId, archived: false }).map(
+        data: ReactiveCache.getSwimlanes({ boardId: paramBoardId, archived: false }).map(
           function(doc) {
             return {
               _id: doc._id,
@@ -471,7 +471,7 @@ if (Meteor.isServer) {
       const id = Swimlanes.insert({
         title: req.body.title,
         boardId: paramBoardId,
-        sort: board.swimlanes().count(),
+        sort: board.swimlanes().length,
       });
       JsonRoutes.sendResult(res, {
         code: 200,