Переглянути джерело

Move every Meteor.user() to the ReactiveCache

Martin Filser 2 роки тому
батько
коміт
5e3a9dc059
42 змінених файлів з 211 додано та 252 видалено
  1. 4 4
      client/components/activities/activities.js
  2. 3 1
      client/components/boards/boardArchive.js
  3. 6 7
      client/components/boards/boardBody.js
  4. 11 10
      client/components/boards/boardHeader.js
  5. 17 34
      client/components/boards/boardsList.js
  6. 1 1
      client/components/cards/attachments.js
  7. 17 17
      client/components/cards/cardDetails.js
  8. 8 8
      client/components/cards/checklists.js
  9. 2 1
      client/components/cards/minicard.js
  10. 2 10
      client/components/lists/list.js
  11. 3 6
      client/components/lists/listBody.js
  12. 8 7
      client/components/lists/listHeader.js
  13. 2 1
      client/components/main/dueCards.js
  14. 1 1
      client/components/main/layouts.js
  15. 3 1
      client/components/notifications/notification.js
  16. 3 3
      client/components/notifications/notificationsDrawer.js
  17. 3 1
      client/components/rules/actions/boardActions.js
  18. 11 11
      client/components/sidebar/sidebar.js
  19. 2 1
      client/components/sidebar/sidebarArchives.js
  20. 4 2
      client/components/sidebar/sidebarFilters.js
  21. 3 2
      client/components/swimlanes/swimlaneHeader.js
  22. 3 21
      client/components/swimlanes/swimlanes.js
  23. 3 9
      client/components/users/userAvatar.js
  24. 13 12
      client/components/users/userHeader.js
  25. 5 0
      client/config/blazeHelpers.js
  26. 2 1
      client/lib/datepicker.js
  27. 1 1
      client/lib/dialogWithBoardSwimlaneList.js
  28. 2 1
      client/lib/filter.js
  29. 3 2
      client/lib/i18n.js
  30. 4 8
      client/lib/keyboard.js
  31. 7 7
      client/lib/utils.js
  32. 4 8
      models/boards.js
  33. 1 1
      models/integrations.js
  34. 6 6
      models/org.js
  35. 1 1
      models/settings.js
  36. 0 5
      models/swimlanes.js
  37. 6 6
      models/team.js
  38. 27 29
      models/users.js
  39. 1 1
      server/notifications/outgoing.js
  40. 3 2
      server/publications/cards.js
  41. 3 1
      server/publications/notifications.js
  42. 2 1
      server/statistics.js

+ 4 - 4
client/components/activities/activities.js

@@ -25,7 +25,7 @@ BlazeComponent.extendComponent({
         searchId = Session.get(`current${capitalizedMode}`);
       }
       const limit = this.page.get() * activitiesPerPage;
-      const user = Meteor.user();
+      const user = ReactiveCache.getCurrentUser();
       const hideSystem = user ? user.hasHiddenSystemMessages() : false;
       if (searchId === null) return;
 
@@ -283,7 +283,7 @@ Template.activity.helpers({
 
 Template.commentReactions.events({
   'click .reaction'(event) {
-    if (Meteor.user().isBoardMember()) {
+    if (ReactiveCache.getCurrentUser().isBoardMember()) {
       const codepoint = event.currentTarget.dataset['codepoint'];
       const commentId = Template.instance().data.commentId;
       const cardComment = CardComments.findOne({_id: commentId});
@@ -295,7 +295,7 @@ Template.commentReactions.events({
 
 Template.addReactionPopup.events({
   'click .add-comment-reaction'(event) {
-    if (Meteor.user().isBoardMember()) {
+    if (ReactiveCache.getCurrentUser().isBoardMember()) {
       const codepoint = event.currentTarget.dataset['codepoint'];
       const commentId = Template.instance().data.commentId;
       const cardComment = CardComments.findOne({_id: commentId});
@@ -326,7 +326,7 @@ Template.addReactionPopup.helpers({
 
 Template.commentReactions.helpers({
   isSelected(userIds) {
-    return userIds.includes(Meteor.user()._id);
+    return Meteor.userId() && userIds.includes(Meteor.userId());
   },
   userNames(userIds) {
     return Users.find({_id: {$in: userIds}})

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

@@ -1,10 +1,12 @@
+import { ReactiveCache } from '/imports/reactiveCache';
+
 BlazeComponent.extendComponent({
   onCreated() {
     this.subscribe('archivedBoards');
   },
 
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
 
   archivedBoards() {

+ 6 - 7
client/components/boards/boardBody.js

@@ -205,11 +205,10 @@ BlazeComponent.extendComponent({
       }
 
       // Disable drag-dropping if the current user is not a board member
-      //$swimlanesDom.sortable('option', 'disabled', !userIsMember());
       $swimlanesDom.sortable(
         'option',
         'disabled',
-        !Meteor.user() || !Meteor.user().isBoardAdmin(),
+        !ReactiveCache.getCurrentUser()?.isBoardAdmin(),
       );
     });
 
@@ -232,7 +231,7 @@ BlazeComponent.extendComponent({
   },
 
   isViewSwimlanes() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).boardView === 'board-view-swimlanes';
     } else {
@@ -243,7 +242,7 @@ BlazeComponent.extendComponent({
   },
 
   isViewLists() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).boardView === 'board-view-lists';
     } else {
@@ -252,7 +251,7 @@ BlazeComponent.extendComponent({
   },
 
   isViewCalendar() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).boardView === 'board-view-cal';
     } else {
@@ -418,7 +417,7 @@ BlazeComponent.extendComponent({
       },
       select: function(startDate) {
         const currentBoard = Utils.getCurrentBoard();
-        const currentUser = Meteor.user();
+        const currentUser = ReactiveCache.getCurrentUser();
         const $modal = $(`
           <div class="modal fade" tabindex="-1" role="dialog">
             <div class="modal-dialog justify-content-center align-items-center" role="document">
@@ -459,7 +458,7 @@ BlazeComponent.extendComponent({
     };
   },
   isViewCalendar() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).boardView === 'board-view-cal';
     } else {

+ 11 - 10
client/components/boards/boardHeader.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { TAPi18n } from '/imports/i18n';
 
 /*
@@ -64,7 +65,7 @@ BlazeComponent.extendComponent({
 
   isStarred() {
     const boardId = Session.get('currentBoard');
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     return user && user.hasStarred(boardId);
   },
 
@@ -75,7 +76,7 @@ BlazeComponent.extendComponent({
   },
   /*
   showSort() {
-    return Meteor.user().hasSortBy();
+    return ReactiveCache.getCurrentUser().hasSortBy();
   },
   directionClass() {
     return this.currentDirection() === -1 ? DOWNCLS : UPCLS;
@@ -85,10 +86,10 @@ BlazeComponent.extendComponent({
     Meteor.call('setListSortBy', direction + this.currentListSortBy());
   },
   currentDirection() {
-    return Meteor.user().getListSortByDirection();
+    return ReactiveCache.getCurrentUser().getListSortByDirection();
   },
   currentListSortBy() {
-    return Meteor.user().getListSortBy();
+    return ReactiveCache.getCurrentUser().getListSortBy();
   },
   listSortShortDesc() {
     return `list-label-short-${this.currentListSortBy()}`;
@@ -99,7 +100,7 @@ BlazeComponent.extendComponent({
       {
         'click .js-edit-board-title': Popup.open('boardChangeTitle'),
         'click .js-star-board'() {
-          Meteor.user().toggleBoardStar(Session.get('currentBoard'));
+          ReactiveCache.getCurrentUser().toggleBoardStar(Session.get('currentBoard'));
         },
         'click .js-open-board-menu': Popup.open('boardMenu'),
         'click .js-change-visibility': Popup.open('boardChangeVisibility'),
@@ -306,7 +307,7 @@ const CreateBoard = BlazeComponent.extendComponent({
   onSubmit(event) {
     super.onSubmit(event);
     // Immediately star boards crated with the headerbar popup.
-    Meteor.user().toggleBoardStar(this.boardId.get());
+    ReactiveCache.getCurrentUser().toggleBoardStar(this.boardId.get());
   }
 }.register('headerBarCreateBoardPopup'));
 
@@ -377,7 +378,7 @@ BlazeComponent.extendComponent({
   allowedSortValues() {
     const types = [];
     const pushed = {};
-    Meteor.user()
+    ReactiveCache.getCurrentUser()
       .getListSortTypes()
       .forEach(type => {
         const key = type.replace(/^-/, '');
@@ -393,16 +394,16 @@ BlazeComponent.extendComponent({
     return types;
   },
   Direction() {
-    return Meteor.user().getListSortByDirection() === -1
+    return ReactiveCache.getCurrentUser().getListSortByDirection() === -1
       ? this.downClass
       : this.upClass;
   },
   sortby() {
-    return Meteor.user().getListSortBy();
+    return ReactiveCache.getCurrentUser().getListSortBy();
   },
 
   setSortBy(type = null) {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     if (type === null) {
       type = user._getListSortBy();
     } else {

+ 17 - 34
client/components/boards/boardsList.js

@@ -31,10 +31,10 @@ Template.boardListHeaderBar.helpers({
     //}
   },
   templatesBoardId() {
-    return Meteor.user() && Meteor.user().getTemplatesBoardId();
+    return ReactiveCache.getCurrentUser()?.getTemplatesBoardId();
   },
   templatesBoardSlug() {
-    return Meteor.user() && Meteor.user().getTemplatesBoardSlug();
+    return ReactiveCache.getCurrentUser()?.getTemplatesBoardSlug();
   },
 });
 
@@ -42,7 +42,7 @@ BlazeComponent.extendComponent({
   onCreated() {
     Meteor.subscribe('setting');
     Meteor.subscribe('tableVisibilityModeSettings');
-    let currUser = Meteor.user();
+    let currUser = ReactiveCache.getCurrentUser();
     let userLanguage;
     if (currUser && currUser.profile) {
       userLanguage = currUser.profile.language
@@ -100,51 +100,34 @@ BlazeComponent.extendComponent({
     });
   },
   userHasTeams() {
-    if (Meteor.user() != null && Meteor.user().teams && Meteor.user().teams.length > 0)
+    if (ReactiveCache.getCurrentUser()?.teams?.length > 0)
       return true;
     else
       return false;
   },
   teamsDatas() {
-    if (Meteor.user().teams)
-      return Meteor.user().teams.sort((a, b) => a.teamDisplayName.localeCompare(b.teamDisplayName));
+    const teams = ReactiveCache.getCurrentUser()?.teams
+    if (teams)
+      return teams.sort((a, b) => a.teamDisplayName.localeCompare(b.teamDisplayName));
     else
       return [];
   },
   userHasOrgs() {
-    if (Meteor.user() != null && Meteor.user().orgs && Meteor.user().orgs.length > 0)
+    if (ReactiveCache.getCurrentUser()?.orgs?.length > 0)
       return true;
     else
       return false;
   },
-  /*
-    userHasTemplates(){
-      if(Meteor.user() != null && Meteor.user().orgs && Meteor.user().orgs.length > 0)
-        return true;
-      else
-        return false;
-    },
-  */
   orgsDatas() {
-    if (Meteor.user().orgs)
-      return Meteor.user().orgs.sort((a, b) => a.orgDisplayName.localeCompare(b.orgDisplayName));
+    const orgs = ReactiveCache.getCurrentUser()?.orgs;
+    if (orgs)
+      return orgs.sort((a, b) => a.orgDisplayName.localeCompare(b.orgDisplayName));
     else
       return [];
   },
   userHasOrgsOrTeams() {
-    let boolUserHasOrgs;
-    if (Meteor.user() != null && Meteor.user().orgs && Meteor.user().orgs.length > 0)
-      boolUserHasOrgs = true;
-    else
-      boolUserHasOrgs = false;
-
-    let boolUserHasTeams;
-    if (Meteor.user() != null && Meteor.user().teams && Meteor.user().teams.length > 0)
-      boolUserHasTeams = true;
-    else
-      boolUserHasTeams = false;
-
-    return (boolUserHasOrgs || boolUserHasTeams);
+    const ret = this.userHasOrgs() || this.userHasTeams();
+    return ret;
   },
   boards() {
     let query = {
@@ -227,11 +210,11 @@ BlazeComponent.extendComponent({
   },
 
   isStarred() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     return user && user.hasStarred(this.currentData()._id);
   },
   isAdministrable() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     return user && user.isBoardAdmin(this.currentData()._id);
   },
 
@@ -246,7 +229,7 @@ BlazeComponent.extendComponent({
   },
 
   isInvited() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     return user && user.isInvitedTo(this.currentData()._id);
   },
 
@@ -256,7 +239,7 @@ BlazeComponent.extendComponent({
         'click .js-add-board': Popup.open('createBoard'),
         'click .js-star-board'(evt) {
           const boardId = this.currentData()._id;
-          Meteor.user().toggleBoardStar(boardId);
+          ReactiveCache.getCurrentUser().toggleBoardStar(boardId);
           evt.preventDefault();
         },
         'click .js-clone-board'(evt) {

+ 1 - 1
client/components/cards/attachments.js

@@ -167,7 +167,7 @@ Template.attachmentViewer.events({
 
 Template.attachmentGallery.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
   fileSize(size) {
     const ret = filesize(size);

+ 17 - 17
client/components/cards/cardDetails.js

@@ -64,16 +64,16 @@ BlazeComponent.extendComponent({
   },
 
   hiddenSystemMessages() {
-    return Meteor.user().hasHiddenSystemMessages();
+    return ReactiveCache.getCurrentUser().hasHiddenSystemMessages();
   },
 
   customFieldsGrid() {
-    return Meteor.user().hasCustomFieldsGrid();
+    return ReactiveCache.getCurrentUser().hasCustomFieldsGrid();
   },
 
 
   cardMaximized() {
-    return !Utils.getPopupCardId() && Meteor.user().hasCardMaximized();
+    return !Utils.getPopupCardId() && ReactiveCache.getCurrentUser().hasCardMaximized();
   },
 
   scrollParentContainer() {
@@ -193,7 +193,7 @@ BlazeComponent.extendComponent({
         cardId: card._id,
         boardId: card.boardId,
         listId: card.listId,
-        user: Meteor.user().username,
+        user: ReactiveCache.getCurrentUser().username,
         url: '',
       };
 
@@ -288,7 +288,7 @@ BlazeComponent.extendComponent({
     });
 
     function userIsMember() {
-      return Meteor.user() && Meteor.user().isBoardMember();
+      return ReactiveCache.getCurrentUser()?.isBoardMember();
     }
 
     // Disable sorting if the current user is not a board member
@@ -652,7 +652,7 @@ Template.cardDetailsActionsPopup.helpers({
   },
 
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
 });
 
@@ -814,11 +814,11 @@ Template.editCardAssignerForm.events({
 /** Move Card Dialog */
 (class extends DialogWithBoardSwimlaneList {
   getDialogOptions() {
-    const ret = Meteor.user().getMoveAndCopyDialogOptions();
+    const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
     return ret;
   }
   setDone(boardId, swimlaneId, listId, options) {
-    Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
+    ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
     const card = this.data();
     const minOrder = card.getMinSort(listId, swimlaneId);
     card.move(boardId, swimlaneId, listId, minOrder - 1);
@@ -828,11 +828,11 @@ Template.editCardAssignerForm.events({
 /** Copy Card Dialog */
 (class extends DialogWithBoardSwimlaneList {
   getDialogOptions() {
-    const ret = Meteor.user().getMoveAndCopyDialogOptions();
+    const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
     return ret;
   }
   setDone(boardId, swimlaneId, listId, options) {
-    Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
+    ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
     const card = this.data();
 
     // const textarea = $('#copy-card-title');
@@ -855,11 +855,11 @@ Template.editCardAssignerForm.events({
 /** Convert Checklist-Item to card dialog */
 (class extends DialogWithBoardSwimlaneList {
   getDialogOptions() {
-    const ret = Meteor.user().getMoveAndCopyDialogOptions();
+    const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
     return ret;
   }
   setDone(boardId, swimlaneId, listId, options) {
-    Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
+    ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
     const card = this.data();
 
     const textarea = this.$('#copy-card-title');
@@ -885,11 +885,11 @@ Template.editCardAssignerForm.events({
 /** Copy many cards dialog */
 (class extends DialogWithBoardSwimlaneList {
   getDialogOptions() {
-    const ret = Meteor.user().getMoveAndCopyDialogOptions();
+    const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
     return ret;
   }
   setDone(boardId, swimlaneId, listId, options) {
-    Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
+    ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
     const card = this.data();
 
     const textarea = this.$('#copy-card-title');
@@ -966,7 +966,7 @@ BlazeComponent.extendComponent({
         archived: false,
         'members.userId': Meteor.userId(),
         _id: {
-          $ne: Meteor.user().getTemplatesBoardId(),
+          $ne: ReactiveCache.getCurrentUser().getTemplatesBoardId(),
         },
       },
       {
@@ -1563,8 +1563,8 @@ EscapeActions.register(
   () => {
     // if card description diverges from database due to editing
     // ask user whether changes should be applied
-    if (Meteor.user()) {
-      if (Meteor.user().profile.rescueCardDescription == true) {
+    if (ReactiveCache.getCurrentUser()) {
+      if (ReactiveCache.getCurrentUser().profile.rescueCardDescription == true) {
         currentDescription = document.getElementsByClassName("editor js-new-description-input").item(0)
         if (currentDescription?.value && !(currentDescription.value === Utils.getCurrentCard().getDescription())) {
           if (confirm(TAPi18n.__('rescue-card-description-dialogue'))) {

+ 8 - 8
client/components/cards/checklists.js

@@ -55,7 +55,7 @@ BlazeComponent.extendComponent({
     });
 
     function userIsMember() {
-      return Meteor.user() && Meteor.user().isBoardMember();
+      return ReactiveCache.getCurrentUser()?.isBoardMember();
     }
 
     // Disable sorting if the current user is not a board member
@@ -237,7 +237,7 @@ BlazeComponent.extendComponent({
       {
         archived: false,
         'members.userId': Meteor.userId(),
-        _id: { $ne: Meteor.user().getTemplatesBoardId() },
+        _id: { $ne: ReactiveCache.getCurrentUser().getTemplatesBoardId() },
       },
       {
         sort: { sort: 1 /* boards default sorting */ },
@@ -274,7 +274,7 @@ Template.checklists.helpers({
     return ret;
   },
   hideCheckedItems() {
-    const currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) return currentUser.hasHideCheckedItems();
     return false;
   },
@@ -338,7 +338,7 @@ BlazeComponent.extendComponent({
 
 Template.checklistItemDetail.helpers({
   hideCheckedItems() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     if (user) return user.hasHideCheckedItems();
     return false;
   },
@@ -364,11 +364,11 @@ BlazeComponent.extendComponent({
 /** Move Checklist Dialog */
 (class extends DialogWithBoardSwimlaneListCard {
   getDialogOptions() {
-    const ret = Meteor.user().getMoveChecklistDialogOptions();
+    const ret = ReactiveCache.getCurrentUser().getMoveChecklistDialogOptions();
     return ret;
   }
   setDone(cardId, options) {
-    Meteor.user().setMoveChecklistDialogOption(this.currentBoardId, options);
+    ReactiveCache.getCurrentUser().setMoveChecklistDialogOption(this.currentBoardId, options);
     this.data().checklist.move(cardId);
   }
 }).register('moveChecklistPopup');
@@ -376,11 +376,11 @@ BlazeComponent.extendComponent({
 /** Copy Checklist Dialog */
 (class extends DialogWithBoardSwimlaneListCard {
   getDialogOptions() {
-    const ret = Meteor.user().getCopyChecklistDialogOptions();
+    const ret = ReactiveCache.getCurrentUser().getCopyChecklistDialogOptions();
     return ret;
   }
   setDone(cardId, options) {
-    Meteor.user().setCopyChecklistDialogOption(this.currentBoardId, options);
+    ReactiveCache.getCurrentUser().setCopyChecklistDialogOption(this.currentBoardId, options);
     this.data().checklist.copy(cardId);
   }
 }).register('copyChecklistPopup');

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

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { TAPi18n } from '/imports/i18n';
 import { CustomFieldStringTemplate } from '/client/lib/customFields'
 
@@ -113,7 +114,7 @@ BlazeComponent.extendComponent({
 
 Template.minicard.helpers({
   hiddenMinicardLabelText() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).hiddenMinicardLabelText;
     } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {

+ 2 - 10
client/components/lists/list.js

@@ -24,14 +24,6 @@ BlazeComponent.extendComponent({
   onRendered() {
     const boardComponent = this.parentComponent().parentComponent();
 
-    function userIsMember() {
-      return (
-        Meteor.user() &&
-        Meteor.user().isBoardMember() &&
-        !Meteor.user().isCommentOnly()
-      );
-    }
-
     const itemsSelector = '.js-minicard:not(.placeholder, .js-card-composer)';
     const $cards = this.$('.js-minicards');
 
@@ -170,9 +162,9 @@ BlazeComponent.extendComponent({
           'option',
           'disabled',
           // Disable drag-dropping when user is not member
-          !userIsMember(),
+          !Utils.canModifyBoard(),
           // Not disable drag-dropping while in multi-selection mode
-          // MultiSelection.isActive() || !userIsMember(),
+          // MultiSelection.isActive() || !Utils.canModifyBoard(),
         );
       }
     });

+ 3 - 6
client/components/lists/listBody.js

@@ -216,10 +216,7 @@ BlazeComponent.extendComponent({
   canSeeAddCard() {
     return (
       !this.reachedWipLimit() &&
-      Meteor.user() &&
-      Meteor.user().isBoardMember() &&
-      !Meteor.user().isCommentOnly() &&
-      !Meteor.user().isWorker()
+      Utils.canModifyCard()
     );
   },
 
@@ -620,7 +617,7 @@ BlazeComponent.extendComponent({
 
     this.board = {};
     if (this.isTemplateSearch) {
-      const boardId = (Meteor.user().profile || {}).templatesBoardId;
+      const boardId = (ReactiveCache.getCurrentUser().profile || {}).templatesBoardId;
       if (boardId) {
         this.board = ReactiveCache.getBoard(boardId);
       }
@@ -789,7 +786,7 @@ BlazeComponent.extendComponent({
       Meteor.settings.public.sandstorm;
 
     if (isSandstorm) {
-      const user = Meteor.user();
+      const user = ReactiveCache.getCurrentUser();
       if (user) {
         if (Utils.boardView() === 'board-view-swimlanes') {
           this.swimlaneId = this.parentComponent()

+ 8 - 7
client/components/lists/listHeader.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { TAPi18n } from '/imports/i18n';
 
 let listsColors;
@@ -12,12 +13,12 @@ BlazeComponent.extendComponent({
       (!list.getWipLimit('enabled') ||
         list.getWipLimit('soft') ||
         !this.reachedWipLimit()) &&
-      !Meteor.user().isWorker()
+      !ReactiveCache.getCurrentUser().isWorker()
     );
   },
 
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
   starred(check = undefined) {
     const list = Template.currentData();
@@ -47,9 +48,9 @@ BlazeComponent.extendComponent({
   },
 
   limitToShowCardsCount() {
-    const currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
-      return Meteor.user().getLimitToShowCardsCount();
+      return currentUser.getLimitToShowCardsCount();
     } else {
       return false;
     }
@@ -123,13 +124,13 @@ BlazeComponent.extendComponent({
 
 Template.listHeader.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   }
 });
 
 Template.listActionPopup.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
 
   isWipLimitEnabled() {
@@ -279,7 +280,7 @@ Template.listMorePopup.events({
 
 Template.listHeader.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
 });
 

+ 2 - 1
client/components/main/dueCards.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { CardSearchPagedComponent } from '../../lib/cardSearch';
 import {
   OPERATOR_HAS,
@@ -66,7 +67,7 @@ class DueCardsComponent extends CardSearchPagedComponent {
     });
 
     if (Utils.dueCardsView() !== 'all') {
-      queryParams.addPredicate(OPERATOR_USER, Meteor.user().username);
+      queryParams.addPredicate(OPERATOR_USER, ReactiveCache.getCurrentUser().username);
     }
 
     this.runGlobalSearch(queryParams);

+ 1 - 1
client/components/main/layouts.js

@@ -51,7 +51,7 @@ Template.userFormsLayout.onCreated(function () {
     }
   });
 
-  if (!Meteor.user()?.profile) {
+  if (!ReactiveCache.getCurrentUser()?.profile) {
       Meteor.call('isOidcRedirectionEnabled', (_, result) => {
         if (result) {
           AccountsTemplates.options.socialLoginStyle = 'redirect';

+ 3 - 1
client/components/notifications/notification.js

@@ -1,3 +1,5 @@
+import { ReactiveCache } from '/imports/reactiveCache';
+
 Template.notification.events({
   'click .read-status .materialCheckBox'() {
     const update = {};
@@ -7,7 +9,7 @@ Template.notification.events({
     Users.update(Meteor.userId(), { $set: update });
   },
   'click .remove a'() {
-    Meteor.user().removeNotification(this.activityData._id);
+    ReactiveCache.getCurrentUser().removeNotification(this.activityData._id);
   },
 });
 

+ 3 - 3
client/components/notifications/notificationsDrawer.js

@@ -19,7 +19,7 @@ Template.notificationsDrawer.helpers({
   },
   readNotifications() {
     const readNotifications = _.filter(
-      Meteor.user().profile.notifications,
+      ReactiveCache.getCurrentUser().profile.notifications,
       v => !!v.read,
     );
     return readNotifications.length;
@@ -28,7 +28,7 @@ Template.notificationsDrawer.helpers({
 
 Template.notificationsDrawer.events({
   'click .all-read'() {
-    const notifications = Meteor.user().profile.notifications;
+    const notifications = ReactiveCache.getCurrentUser().profile.notifications;
     for (const index in notifications) {
       if (notifications.hasOwnProperty(index) && !notifications[index].read) {
         const update = {};
@@ -44,7 +44,7 @@ Template.notificationsDrawer.events({
     Session.set('showReadNotifications', !Session.get('showReadNotifications'));
   },
   'click .remove-read'() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     for (const notification of user.profile.notifications) {
       if (notification.read) {
         user.removeNotification(notification.activity);

+ 3 - 1
client/components/rules/actions/boardActions.js

@@ -1,3 +1,5 @@
+import { ReactiveCache } from '/imports/reactiveCache';
+
 BlazeComponent.extendComponent({
   onCreated() {},
 
@@ -7,7 +9,7 @@ BlazeComponent.extendComponent({
         archived: false,
         'members.userId': Meteor.userId(),
         _id: {
-          $ne: Meteor.user().getTemplatesBoardId(),
+          $ne: ReactiveCache.getCurrentUser().getTemplatesBoardId(),
         },
       },
       {

+ 11 - 11
client/components/sidebar/sidebar.js

@@ -112,7 +112,7 @@ BlazeComponent.extendComponent({
         'click .js-toggle-sidebar': this.toggle,
         'click .js-back-home': this.setView,
         'click .js-toggle-minicard-label-text'() {
-          currentUser = Meteor.user();
+          currentUser = ReactiveCache.getCurrentUser();
           if (currentUser) {
             Meteor.call('toggleMinicardLabelText');
           } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
@@ -138,7 +138,7 @@ Blaze.registerHelper('Sidebar', () => Sidebar);
 
 Template.homeSidebar.helpers({
   hiddenMinicardLabelText() {
-    currentUser = Meteor.user();
+    currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).hiddenMinicardLabelText;
     } else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
@@ -173,7 +173,7 @@ Template.memberPopup.helpers({
     return ReactiveCache.getUser(this.userId);
   },
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
   memberType() {
     const type = ReactiveCache.getUser(this.userId).isBoardAdmin() ? 'admin' : 'normal';
@@ -249,7 +249,7 @@ Template.boardMenuPopup.onCreated(function() {
 
 Template.boardMenuPopup.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
   withApi() {
     return Template.instance().apiEnabled.get();
@@ -359,11 +359,11 @@ BlazeComponent.extendComponent({
 
 Template.membersWidget.helpers({
   isInvited() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     return user && user.isInvitedTo(Session.get('currentBoard'));
   },
   isWorker() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     if (user) {
       return Meteor.call(Boards.hasWorker(user.memberId));
     } else {
@@ -371,7 +371,7 @@ Template.membersWidget.helpers({
     }
   },
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
   AtLeastOneOrgWasCreated(){
     let orgs = Org.find({}, {sort: { createdAt: -1 }});
@@ -407,13 +407,13 @@ Template.membersWidget.events({
   },
   'click .js-member-invite-accept'() {
     const boardId = Session.get('currentBoard');
-    Meteor.user().removeInvite(boardId);
+    ReactiveCache.getCurrentUser().removeInvite(boardId);
   },
   'click .js-member-invite-decline'() {
     const boardId = Session.get('currentBoard');
     Meteor.call('quitBoard', boardId, (err, ret) => {
       if (!err && ret) {
-        Meteor.user().removeInvite(boardId);
+        ReactiveCache.getCurrentUser().removeInvite(boardId);
         FlowRouter.go('home');
       }
     });
@@ -605,7 +605,7 @@ Template.labelsWidget.events({
 
 Template.labelsWidget.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
 });
 
@@ -640,7 +640,7 @@ function draggableMembersLabelsWidgets() {
       });
 
       function userIsMember() {
-        return Meteor.user() && Meteor.user().isBoardMember();
+        return ReactiveCache.getCurrentUser()?.isBoardMember();
       }
 
       this.autorun(() => {

+ 2 - 1
client/components/sidebar/sidebarArchives.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { TAPi18n } from '/imports/i18n';
 
 //archivedRequested = false;
@@ -159,7 +160,7 @@ BlazeComponent.extendComponent({
 
 Template.archivesSidebar.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
   isWorker() {
     const currentBoard = Utils.getCurrentBoard();

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

@@ -1,3 +1,5 @@
+import { ReactiveCache } from '/imports/reactiveCache';
+
 const subManager = new SubsManager();
 
 BlazeComponent.extendComponent({
@@ -171,10 +173,10 @@ BlazeComponent.extendComponent({
 
 Template.multiselectionSidebar.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
   isCommentOnly() {
-    return Meteor.user().isCommentOnly();
+    return ReactiveCache.getCurrentUser().isCommentOnly();
   },
 });
 

+ 3 - 2
client/components/swimlanes/swimlaneHeader.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 const { calculateIndexData } = Utils;
 
 let swimlaneColors;
@@ -30,7 +31,7 @@ BlazeComponent.extendComponent({
 
 Template.swimlaneFixedHeader.helpers({
   isBoardAdmin() {
-    return Meteor.user().isBoardAdmin();
+    return ReactiveCache.getCurrentUser().isBoardAdmin();
   },
 });
 
@@ -47,7 +48,7 @@ Template.swimlaneActionPopup.events({
 
 Template.swimlaneActionPopup.events({
   isCommentOnly() {
-    return Meteor.user().isCommentOnly();
+    return ReactiveCache.getCurrentUser().isCommentOnly();
   },
 });
 

+ 3 - 21
client/components/swimlanes/swimlanes.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 const { calculateIndex } = Utils;
 
 function currentListIsInThisSwimlane(swimlaneId) {
@@ -10,7 +11,7 @@ function currentListIsInThisSwimlane(swimlaneId) {
 
 function currentCardIsInThisList(listId, swimlaneId) {
   const currentCard = Utils.getCurrentCard();
-  //const currentUser = Meteor.user();
+  //const currentUser = ReactiveCache.getCurrentUser();
   if (
     //currentUser &&
     //currentUser.profile &&
@@ -104,15 +105,6 @@ function initSortable(boardComponent, $listsDom) {
     },
   });
 
-  //function userIsMember() {
-  //  return (
-  //    Meteor.user() &&
-  //    Meteor.user().isBoardMember() &&
-  //    !Meteor.user().isCommentOnly() &&
-  //    !Meteor.user().isWorker()
-  //  );
-  //}
-
   boardComponent.autorun(() => {
     if (Utils.isTouchScreenOrShowDesktopDragHandles()) {
       $listsDom.sortable({
@@ -129,11 +121,7 @@ function initSortable(boardComponent, $listsDom) {
       $listsDom.sortable(
         'option',
         'disabled',
-        // Disable drag-dropping when user is not member/is worker
-        //!userIsMember() || Meteor.user().isWorker(),
-        !Meteor.user() || !Meteor.user().isBoardAdmin(),
-        // Not disable drag-dropping while in multi-selection mode
-        // MultiSelection.isActive() || !userIsMember(),
+        !ReactiveCache.getCurrentUser()?.isBoardAdmin(),
       );
     }
   });
@@ -294,12 +282,6 @@ BlazeComponent.extendComponent({
 Template.swimlane.helpers({
   canSeeAddList() {
     return Meteor.user().isBoardAdmin();
-    /*
-      Meteor.user() &&
-      Meteor.user().isBoardMember() &&
-      !Meteor.user().isCommentOnly() &&
-      !Meteor.user().isWorker()
-      */
   },
 });
 

+ 3 - 9
client/components/users/userAvatar.js

@@ -91,9 +91,6 @@ Template.boardOrgRow.helpers({
   orgData() {
     return Org.findOne(this.orgId);
   },
-  currentUser(){
-    return Meteor.user();
-  },
 });
 
 Template.boardOrgName.helpers({
@@ -153,9 +150,6 @@ Template.boardTeamRow.helpers({
   teamData() {
     return Team.findOne(this.teamId);
   },
-  currentUser(){
-    return Meteor.user();
-  },
 });
 
 Template.boardTeamName.helpers({
@@ -182,20 +176,20 @@ BlazeComponent.extendComponent({
   },
 
   isSelected() {
-    const userProfile = Meteor.user().profile;
+    const userProfile = ReactiveCache.getCurrentUser().profile;
     const avatarUrl = userProfile && userProfile.avatarUrl;
     const currentAvatarUrl = `${this.currentData().link()}?auth=false&brokenIsFine=true`;
     return avatarUrl === currentAvatarUrl;
   },
 
   noAvatarUrl() {
-    const userProfile = Meteor.user().profile;
+    const userProfile = ReactiveCache.getCurrentUser().profile;
     const avatarUrl = userProfile && userProfile.avatarUrl;
     return !avatarUrl;
   },
 
   setAvatar(avatarUrl) {
-    Meteor.user().setAvatarUrl(avatarUrl);
+    ReactiveCache.getCurrentUser().setAvatarUrl(avatarUrl);
   },
 
   setError(error) {

+ 13 - 12
client/components/users/userHeader.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { TAPi18n } from '/imports/i18n';
 
 Template.headerUserBar.events({
@@ -13,18 +14,18 @@ BlazeComponent.extendComponent({
 
 Template.memberMenuPopup.helpers({
   templatesBoardId() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
-      return Meteor.user().getTemplatesBoardId();
+      return currentUser.getTemplatesBoardId();
     } else {
       // No need to getTemplatesBoardId on public board
       return false;
     }
   },
   templatesBoardSlug() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
-      return Meteor.user().getTemplatesBoardSlug();
+      return currentUser.getTemplatesBoardSlug();
     } else {
       // No need to getTemplatesBoardSlug() on public board
       return false;
@@ -33,7 +34,7 @@ Template.memberMenuPopup.helpers({
   isSameDomainNameSettingValue(){
     const currSett = Utils.getCurrentSetting();
     if(currSett && currSett != undefined && currSett.disableRegistration && currSett.mailDomainName !== undefined && currSett.mailDomainName != ""){
-      currentUser = Meteor.user();
+      currentUser = ReactiveCache.getCurrentUser();
       if (currentUser) {
         let found = false;
         for(let i = 0; i < currentUser.emails.length; i++) {
@@ -51,7 +52,7 @@ Template.memberMenuPopup.helpers({
       return false;
   },
   isNotOAuth2AuthenticationMethod(){
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return currentUser.authenticationMethod.toLowerCase() != 'oauth2';
     } else {
@@ -185,9 +186,9 @@ Template.editProfilePopup.events({
         'profile.initials': initials,
       },
     });
-    isChangeUserName = username !== Meteor.user().username;
+    isChangeUserName = username !== ReactiveCache.getCurrentUser().username;
     isChangeEmail =
-      email.toLowerCase() !== Meteor.user().emails[0].address.toLowerCase();
+      email.toLowerCase() !== ReactiveCache.getCurrentUser().emails[0].address.toLowerCase();
     if (isChangeUserName && isChangeEmail) {
       Meteor.call(
         'setUsernameAndEmail',
@@ -282,7 +283,7 @@ Template.changeLanguagePopup.events({
 
 Template.changeSettingsPopup.helpers({
   hiddenSystemMessages() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).hasHiddenSystemMessages;
     } else if (window.localStorage.getItem('hasHiddenSystemMessages')) {
@@ -292,7 +293,7 @@ Template.changeSettingsPopup.helpers({
     }
   },
   rescueCardDescription() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).rescueCardDescription;
     } else if (window.localStorage.getItem('rescueCardDescription')) {
@@ -302,9 +303,9 @@ Template.changeSettingsPopup.helpers({
     }
   },
   showCardsCountAt() {
-    currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
-      return Meteor.user().getLimitToShowCardsCount();
+      return currentUser.getLimitToShowCardsCount();
     } else {
       return window.localStorage.getItem('limitToShowCardsCount');
     }

+ 5 - 0
client/config/blazeHelpers.js

@@ -23,6 +23,11 @@ Blaze.registerHelper('currentSetting', () => {
   return ret;
 });
 
+Blaze.registerHelper('currentUser', () => {
+  const ret = ReactiveCache.getCurrentUser();
+  return ret;
+});
+
 Blaze.registerHelper('getUser', userId => ReactiveCache.getUser(userId));
 
 Blaze.registerHelper('concat', (...args) => args.slice(0, -1).join(''));

+ 2 - 1
client/lib/datepicker.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { TAPi18n } from '/imports/i18n';
 import moment from 'moment/min/moment-with-locales';
 
@@ -22,7 +23,7 @@ export class DatePicker extends BlazeComponent {
   }
 
   startDayOfWeek() {
-    const currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return currentUser.getStartDayOfWeek();
     } else {

+ 1 - 1
client/lib/dialogWithBoardSwimlaneList.js

@@ -111,7 +111,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
       {
         archived: false,
         'members.userId': Meteor.userId(),
-        _id: { $ne: Meteor.user().getTemplatesBoardId() },
+        _id: { $ne: ReactiveCache.getCurrentUser().getTemplatesBoardId() },
       },
       {
         sort: { sort: 1 },

+ 2 - 1
client/lib/filter.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import moment from 'moment/min/moment-with-locales';
 
 // Filtered view manager
@@ -107,7 +108,7 @@ class DateFilter {
     // preferred starting day of the week. This date should be added
     // to the moment start of week to get the real start of week date.
     // The default is 1, meaning Monday.
-    const currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     const weekStartDay = currentUser ? currentUser.getStartDayOfWeek() : 1;
 
     if (week === 'this') {

+ 3 - 2
client/lib/i18n.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { TAPi18n } from '/imports/i18n';
 
 // We save the user language preference in the user profile, and use that to set
@@ -5,7 +6,7 @@ import { TAPi18n } from '/imports/i18n';
 // information provided by the browser, and default to english.
 
 Meteor.startup(async () => {
-  let currentUser = Meteor.user();
+  let currentUser = ReactiveCache.getCurrentUser();
   // If we're still logging in, wait (#4967)
   if (!currentUser && Meteor.loggingIn()) {
     await new Promise((resolve) => {
@@ -15,7 +16,7 @@ Meteor.startup(async () => {
         }
       });
     });
-    currentUser = Meteor.user();
+    currentUser = ReactiveCache.getCurrentUser();
   }
   // Select first available language
   const [language] = [

+ 4 - 8
client/lib/keyboard.js

@@ -104,7 +104,7 @@ Mousetrap.bind(numArray, (evt, key) => {
   }
   board = ReactiveCache.getBoard(currentBoardId);
   labels = board.labels;
-  if(MultiSelection.isActive() && Meteor.user().isBoardMember())
+  if(MultiSelection.isActive() && ReactiveCache.getCurrentUser().isBoardMember())
   {
     const cardIds = MultiSelection.getSelectedCardIds();
     for (const cardId of cardIds)
@@ -122,7 +122,7 @@ Mousetrap.bind(numArray, (evt, key) => {
   if (!cardId) {
     return;
   }
-  if (Meteor.user().isBoardMember()) {
+  if (ReactiveCache.getCurrentUser().isBoardMember()) {
     const card = ReactiveCache.getCard(cardId);
     if(num <= board.labels.length)
     {
@@ -142,7 +142,7 @@ Mousetrap.bind('space', evt => {
     return;
   }
 
-  if (Meteor.user().isBoardMember()) {
+  if (ReactiveCache.getCurrentUser().isBoardMember()) {
     const card = ReactiveCache.getCard(cardId);
     card.toggleMember(currentUserId);
     // We should prevent scrolling in card when spacebar is clicked
@@ -162,11 +162,7 @@ Mousetrap.bind('c', evt => {
     return;
   }
 
-  if (
-    Meteor.user().isBoardMember() &&
-    !Meteor.user().isCommentOnly() &&
-    !Meteor.user().isWorker()
-  ) {
+  if (Utils.canModifyBoard()) {
     const card = ReactiveCache.getCard(cardId);
     card.archive();
     // We should prevent scrolling in card when spacebar is clicked

+ 7 - 7
client/lib/utils.js

@@ -68,7 +68,7 @@ Utils = {
     return ret;
   },
   canModifyCard() {
-    const currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     const ret = (
       currentUser &&
       currentUser.isBoardMember() &&
@@ -78,7 +78,7 @@ Utils = {
     return ret;
   },
   canModifyBoard() {
-    const currentUser = Meteor.user();
+    const currentUser = ReactiveCache.getCurrentUser();
     const ret = (
       currentUser &&
       currentUser.isBoardMember() &&
@@ -94,9 +94,9 @@ Utils = {
     window.location.reload();
   },
   setBoardView(view) {
-    currentUser = Meteor.user();
+    currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
-      Meteor.user().setBoardView(view);
+      ReactiveCache.getCurrentUser().setBoardView(view);
     } else if (view === 'board-view-swimlanes') {
       window.localStorage.setItem('boardView', 'board-view-swimlanes'); //true
       Utils.reload();
@@ -118,7 +118,7 @@ Utils = {
   },
 
   boardView() {
-    currentUser = Meteor.user();
+    currentUser = ReactiveCache.getCurrentUser();
     if (currentUser) {
       return (currentUser.profile || {}).boardView;
     } else if (
@@ -334,7 +334,7 @@ Utils = {
 
   // returns if desktop drag handles are enabled
   isShowDesktopDragHandles() {
-    //const currentUser = Meteor.user();
+    //const currentUser = ReactiveCache.getCurrentUser();
     //if (currentUser) {
     //  return (currentUser.profile || {}).showDesktopDragHandles;
     //} else if (window.localStorage.getItem('showDesktopDragHandles')) {
@@ -451,7 +451,7 @@ Utils = {
     window._paq = window._paq || [];
     window._paq.push(['setDoNotTrack', data.doNotTrack]);
     if (data.withUserName) {
-      window._paq.push(['setUserId', Meteor.user().username]);
+      window._paq.push(['setUserId', ReactiveCache.getCurrentUser().username]);
     }
     window._paq.push(['trackPageView']);
     window._paq.push(['enableLinkTracking']);

+ 4 - 8
models/boards.js

@@ -739,17 +739,12 @@ Boards.helpers({
   },
 
   lists() {
-    //currentUser = Meteor.user();
-    //if (currentUser) {
-    //  enabled = Meteor.user().hasSortBy();
-    //}
-    //return enabled ? this.newestLists() : this.draggableLists();
     return this.draggableLists();
   },
 
   newestLists() {
     // sorted lists from newest to the oldest, by its creation date or its cards' last modification date
-    const value = Meteor.user()._getListSortBy();
+    const value = ReactiveCache.getCurrentUser()._getListSortBy();
     const sortKey = { starred: -1, [value[0]]: value[1] }; // [["starred",-1],value];
     return Lists.find(
       {
@@ -1299,9 +1294,10 @@ Boards.mutations({
   },
 
   setBackgroundImageURL(backgroundImageURL) {
-    if(Meteor.user().isBoardAdmin()) {
+    const currentUser = ReactiveCache.getCurrentUser();
+    if(currentUser.isBoardAdmin()) {
       return { $set: { backgroundImageURL } };
-    } else if (Meteor.user().isAdmin()) {
+    } else if (currentUser.isAdmin()) {
       return { $set: { backgroundImageURL } };
     } else {
       return false;

+ 1 - 1
models/integrations.js

@@ -103,7 +103,7 @@ Integrations.Const = {
 const permissionHelper = {
   allow(userId, doc) {
     const user = ReactiveCache.getUser(userId);
-    const isAdmin = user && Meteor.user().isAdmin;
+    const isAdmin = user && ReactiveCache.getCurrentUser().isAdmin;
     return isAdmin || allowIsBoardAdmin(userId, ReactiveCache.getBoard(doc.boardId));
   },
 };

+ 6 - 6
models/org.js

@@ -118,7 +118,7 @@ if (Meteor.isServer) {
       orgWebsite,
       orgIsActive,
     ) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(orgDisplayName, String);
         check(orgDesc, String);
         check(orgShortName, String);
@@ -166,7 +166,7 @@ if (Meteor.isServer) {
       }
     },
     setOrgDisplayName(org, orgDisplayName) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(org, Object);
         check(orgDisplayName, String);
         Org.update(org, {
@@ -177,7 +177,7 @@ if (Meteor.isServer) {
     },
 
     setOrgDesc(org, orgDesc) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(org, Object);
         check(orgDesc, String);
         Org.update(org, {
@@ -187,7 +187,7 @@ if (Meteor.isServer) {
     },
 
     setOrgShortName(org, orgShortName) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(org, Object);
         check(orgShortName, String);
         Org.update(org, {
@@ -197,7 +197,7 @@ if (Meteor.isServer) {
     },
 
     setOrgIsActive(org, orgIsActive) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(org, Object);
         check(orgIsActive, Boolean);
         Org.update(org, {
@@ -238,7 +238,7 @@ if (Meteor.isServer) {
       orgWebsite,
       orgIsActive,
     ) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(org, Object);
         check(orgDisplayName, String);
         check(orgDesc, String);

+ 1 - 1
models/settings.js

@@ -396,7 +396,7 @@ if (Meteor.isServer) {
       if (!Meteor.userId()) {
         throw new Meteor.Error('invalid-user');
       }
-      const user = Meteor.user();
+      const user = ReactiveCache.getCurrentUser();
       if (!user.emails || !user.emails[0] || !user.emails[0].address) {
         throw new Meteor.Error('email-invalid');
       }

+ 0 - 5
models/swimlanes.js

@@ -198,11 +198,6 @@ Swimlanes.helpers({
   },
 
   lists() {
-    //currentUser = Meteor.user();
-    //if (currentUser) {
-    //  enabled = Meteor.user().hasSortBy();
-    //}
-    //return enabled ? this.newestLists() : this.draggableLists();
     return this.draggableLists();
   },
   newestLists() {

+ 6 - 6
models/team.js

@@ -116,7 +116,7 @@ if (Meteor.isServer) {
       teamWebsite,
       teamIsActive,
     ) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(teamDisplayName, String);
         check(teamDesc, String);
         check(teamShortName, String);
@@ -163,7 +163,7 @@ if (Meteor.isServer) {
       }
     },
     setTeamDisplayName(team, teamDisplayName) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(team, Object);
         check(teamDisplayName, String);
         Team.update(team, {
@@ -174,7 +174,7 @@ if (Meteor.isServer) {
     },
 
     setTeamDesc(team, teamDesc) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(team, Object);
         check(teamDesc, String);
         Team.update(team, {
@@ -184,7 +184,7 @@ if (Meteor.isServer) {
     },
 
     setTeamShortName(team, teamShortName) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(team, Object);
         check(teamShortName, String);
         Team.update(team, {
@@ -194,7 +194,7 @@ if (Meteor.isServer) {
     },
 
     setTeamIsActive(team, teamIsActive) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(team, Object);
         check(teamIsActive, Boolean);
         Team.update(team, {
@@ -235,7 +235,7 @@ if (Meteor.isServer) {
       teamWebsite,
       teamIsActive,
     ) {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         check(team, Object);
         check(teamDisplayName, String);
         check(teamDesc, String);

+ 27 - 29
models/users.js

@@ -503,8 +503,8 @@ Users.attachSchema(
 
 Users.allow({
   update(userId, doc) {
-    const user = ReactiveCache.getUser(userId);
-    if ((user && user.isAdmin) || (Meteor.user() && Meteor.user().isAdmin))
+    const user = ReactiveCache.getUser(userId) || ReactiveCache.getCurrentUser();
+    if (user?.isAdmin)
       return true;
     if (!user) {
       return false;
@@ -540,7 +540,7 @@ Users.allow({
 // Non-Admin users can not change to Admin
 Users.deny({
   update(userId, board, fieldNames) {
-    return _.contains(fieldNames, 'isAdmin') && !Meteor.user().isAdmin;
+    return _.contains(fieldNames, 'isAdmin') && !ReactiveCache.getCurrentUser().isAdmin;
   },
   fetch: [],
 });
@@ -1140,50 +1140,50 @@ Users.mutations({
 Meteor.methods({
   setListSortBy(value) {
     check(value, String);
-    Meteor.user().setListSortBy(value);
+    ReactiveCache.getCurrentUser().setListSortBy(value);
   },
   toggleDesktopDragHandles() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     user.toggleDesktopHandles(user.hasShowDesktopDragHandles());
   },
   toggleHideCheckedItems() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     user.toggleHideCheckedItems();
   },
   toggleSystemMessages() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     user.toggleSystem(user.hasHiddenSystemMessages());
   },
   toggleCustomFieldsGrid() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     user.toggleFieldsGrid(user.hasCustomFieldsGrid());
   },
   toggleCardMaximized() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     user.toggleCardMaximized(user.hasCardMaximized());
   },
   toggleMinicardLabelText() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     user.toggleLabelText(user.hasHiddenMinicardLabelText());
   },
   toggleRescueCardDescription() {
-    const user = Meteor.user();
+    const user = ReactiveCache.getCurrentUser();
     user.toggleRescueCardDescription(user.hasRescuedCardDescription());
   },
   changeLimitToShowCardsCount(limit) {
     check(limit, Number);
-    Meteor.user().setShowCardsCountAt(limit);
+    ReactiveCache.getCurrentUser().setShowCardsCountAt(limit);
   },
   changeStartDayOfWeek(startDay) {
     check(startDay, Number);
-    Meteor.user().setStartDayOfWeek(startDay);
+    ReactiveCache.getCurrentUser().setStartDayOfWeek(startDay);
   },
 });
 
 if (Meteor.isServer) {
   Meteor.methods({
     setAllUsersHideSystemMessages() {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         // If setting is missing, add it
         Users.update(
           {
@@ -1241,7 +1241,7 @@ if (Meteor.isServer) {
       check(importUsernames, Array);
       check(userOrgsArray, Array);
       check(userTeamsArray, Array);
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         const nUsersWithUsername = Users.find({
           username,
         }).count();
@@ -1283,7 +1283,7 @@ if (Meteor.isServer) {
     setUsername(username, userId) {
       check(username, String);
       check(userId, String);
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         const nUsersWithUsername = Users.find({
           username,
         }).count();
@@ -1301,7 +1301,7 @@ if (Meteor.isServer) {
     setEmail(email, userId) {
       check(email, String);
       check(username, String);
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         if (Array.isArray(email)) {
           email = email.shift();
         }
@@ -1335,7 +1335,7 @@ if (Meteor.isServer) {
       check(username, String);
       check(email, String);
       check(userId, String);
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         if (Array.isArray(email)) {
           email = email.shift();
         }
@@ -1346,17 +1346,15 @@ if (Meteor.isServer) {
     setPassword(newPassword, userId) {
       check(userId, String);
       check(newPassword, String);
-      if (Meteor.user() && Meteor.user().isAdmin) {
-        if (Meteor.user().isAdmin) {
-          Accounts.setPassword(userId, newPassword);
-        }
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
+        Accounts.setPassword(userId, newPassword);
       }
     },
     setEmailVerified(email, verified, userId) {
       check(email, String);
       check(verified, Boolean);
       check(userId, String);
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         Users.update(userId, {
           $set: {
             emails: [
@@ -1372,7 +1370,7 @@ if (Meteor.isServer) {
     setInitials(initials, userId) {
       check(initials, String);
       check(userId, String);
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         Users.update(userId, {
           $set: {
             'profile.initials': initials,
@@ -1385,7 +1383,7 @@ if (Meteor.isServer) {
       check(username, String);
       check(boardId, String);
 
-      const inviter = Meteor.user();
+      const inviter = ReactiveCache.getCurrentUser();
       const board = ReactiveCache.getBoard(boardId);
       const allowInvite =
         inviter &&
@@ -1526,11 +1524,11 @@ if (Meteor.isServer) {
 
       if (!Meteor.users.findOne(userId))
         throw new Meteor.Error(404, 'User not found');
-      if (!Meteor.user().isAdmin)
+      if (!ReactiveCache.getCurrentUser().isAdmin)
         throw new Meteor.Error(403, 'Permission denied');
 
       ImpersonatedUsers.insert({
-        adminId: Meteor.user()._id,
+        adminId: ReactiveCache.getCurrentUser()._id,
         userId: userId,
         reason: 'clickedImpersonate',
       });
@@ -1546,7 +1544,7 @@ if (Meteor.isServer) {
     setUsersTeamsTeamDisplayName(teamId, teamDisplayName) {
       check(teamId, String);
       check(teamDisplayName, String);
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         Users.find({
           teams: {
             $elemMatch: { teamId: teamId },
@@ -1571,7 +1569,7 @@ if (Meteor.isServer) {
     setUsersOrgsOrgDisplayName(orgId, orgDisplayName) {
       check(orgId, String);
       check(orgDisplayName, String);
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         Users.find({
           orgs: {
             $elemMatch: { orgId: orgId },

+ 1 - 1
server/notifications/outgoing.js

@@ -107,7 +107,7 @@ if (Meteor.isServer) {
   };
   Meteor.methods({
     outgoingWebhooks(integration, description, params) {
-      if (Meteor.user()) {
+      if (ReactiveCache.getCurrentUser()) {
         check(integration, Object);
         check(description, String);
         check(params, Object);

+ 3 - 2
server/publications/cards.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import moment from 'moment/min/moment-with-locales';
 import escapeForRegex from 'escape-string-regexp';
 import Users from '../../models/users';
@@ -78,7 +79,7 @@ Meteor.publish('myCards', function(sessionId) {
   check(sessionId, String);
 
   const queryParams = new QueryParams();
-  queryParams.addPredicate(OPERATOR_USER, Meteor.user().username);
+  queryParams.addPredicate(OPERATOR_USER, ReactiveCache.getCurrentUser().username);
   queryParams.setPredicate(OPERATOR_LIMIT, 200);
 
   const query = buildQuery(queryParams);
@@ -106,7 +107,7 @@ Meteor.publish('myCards', function(sessionId) {
 //   };
 //
 //   if (!allUsers) {
-//     queryParams.users = [Meteor.user().username];
+//     queryParams.users = [ReactiveCache.getCurrentUser().username];
 //   }
 //
 //   return buildQuery(sessionId, queryParams);

+ 3 - 1
server/publications/notifications.js

@@ -1,3 +1,5 @@
+import { ReactiveCache } from '/imports/reactiveCache';
+
 // We use these when displaying notifications in the notificationsDrawer
 
 // gets all activities associated with the current user
@@ -94,7 +96,7 @@ Meteor.publish('notificationUsers', function() {
 });
 
 function activities() {
-  const activityIds = Meteor.user()?.profile?.notifications?.map(v => v.activity) || [];
+  const activityIds = ReactiveCache.getCurrentUser()?.profile?.notifications?.map(v => v.activity) || [];
   let ret = [];
   if (activityIds.length > 0) {
     ret = Activities.find({

+ 2 - 1
server/statistics.js

@@ -1,3 +1,4 @@
+import { ReactiveCache } from '/imports/reactiveCache';
 import { MongoInternals } from 'meteor/mongo';
 
 // Sandstorm context is detected using the METEOR_SETTINGS environment variable
@@ -8,7 +9,7 @@ const isSandstorm =
 if (Meteor.isServer) {
   Meteor.methods({
     getStatistics() {
-      if (Meteor.user() && Meteor.user().isAdmin) {
+      if (ReactiveCache.getCurrentUser()?.isAdmin) {
         const os = require('os');
         const pjson = require('/package.json');
         const statistics = {};