浏览代码

Move every Attachments.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory server/)

Martin Filser 2 年之前
父节点
当前提交
e53b63541e
共有 3 个文件被更改,包括 14 次插入9 次删除
  1. 2 1
      server/publications/attachments.js
  2. 1 1
      server/publications/cards.js
  3. 11 7
      server/publications/notifications.js

+ 2 - 1
server/publications/attachments.js

@@ -2,7 +2,7 @@ import Attachments from '/models/attachments';
 import { ObjectID } from 'bson';
 
 Meteor.publish('attachmentsList', function(limit) {
-  const ret = Attachments.find(
+  const ret = ReactiveCache.getAttachments(
     {},
     {
       fields: {
@@ -19,6 +19,7 @@ Meteor.publish('attachmentsList', function(limit) {
       },
       limit: limit,
     },
+    true,
   ).cursor;
   return ret;
 });

+ 1 - 1
server/publications/cards.js

@@ -793,7 +793,7 @@ function findCards(sessionId, query) {
       ReactiveCache.getUsers({ _id: { $in: users } }, { fields: Users.safeFields }, true),
       ReactiveCache.getChecklists({ cardId: { $in: cards.map(c => c._id) } }, {}, true),
       ReactiveCache.getChecklistItems({ cardId: { $in: cards.map(c => c._id) } }, {}, true),
-      Attachments.find({ 'meta.cardId': { $in: cards.map(c => c._id) } }).cursor,
+      ReactiveCache.getAttachments({ 'meta.cardId': { $in: cards.map(c => c._id) } }, {}, true).cursor,
       ReactiveCache.getCardComments({ cardId: { $in: cards.map(c => c._id) } }, {}, true),
       SessionData.find({ userId, sessionId }),
     ];

+ 11 - 7
server/publications/notifications.js

@@ -10,13 +10,17 @@ Meteor.publish('notificationActivities', () => {
 
 // gets all attachments associated with activities associated with the current user
 Meteor.publish('notificationAttachments', function() {
-  const ret = Attachments.find({
-    _id: {
-      $in: activities()
-        .map(v => v.attachmentId)
-        .filter(v => !!v),
-    }.cursor,
-  });
+  const ret = ReactiveCache.getAttachments(
+    {
+      _id: {
+        $in: activities()
+          .map(v => v.attachmentId)
+          .filter(v => !!v),
+      },
+    },
+    {},
+    true,
+  ).cursor;
   return ret;
 });