소스 검색

fix avatar if Meteor.user() is undefined

Martin Filser 2 년 전
부모
커밋
999c20f3fa
1개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 4
      server/publications/notifications.js

+ 8 - 4
server/publications/notifications.js

@@ -94,8 +94,12 @@ Meteor.publish('notificationUsers', function() {
 });
 
 function activities() {
-  const notifications = Meteor.user().profile.notifications || [];
-  return Activities.find({
-    _id: { $in: notifications.map(v => v.activity) },
-  });
+  const activityIds = Meteor.user()?.profile?.notifications?.map(v => v.activity) || [];
+  let ret = [];
+  if (activityIds.length > 0) {
+    ret = Activities.find({
+      _id: { $in: activityIds },
+    });
+  return ret;
+  }
 }