Pārlūkot izejas kodu

add "currentList" to ReactiveCache

Martin Filser 2 gadi atpakaļ
vecāks
revīzija
c6ee58ef88
2 mainītis faili ar 14 papildinājumiem un 6 dzēšanām
  1. 2 6
      client/config/blazeHelpers.js
  2. 12 0
      client/lib/utils.js

+ 2 - 6
client/config/blazeHelpers.js

@@ -13,12 +13,8 @@ Blaze.registerHelper('currentCard', () => {
 });
 
 Blaze.registerHelper('currentList', () => {
-  const listId = Session.get('currentList');
-  if (listId) {
-    return Lists.findOne(listId);
-  } else {
-    return null;
-  }
+  const ret = Utils.getCurrentList();
+  return ret;
 });
 
 Blaze.registerHelper('getUser', userId => Users.findOne(userId));

+ 12 - 0
client/lib/utils.js

@@ -33,6 +33,10 @@ Utils = {
     const ret = Session.get('popupCardId');
     return ret;
   },
+  getCurrentListId() {
+    const ret = Session.get('currentList');
+    return ret;
+  },
   /** returns the current board
    * <li> returns the current board or the board of the popup card if set
    */
@@ -46,6 +50,14 @@ Utils = {
     const ret = ReactiveCache.getCard(cardId);
     return ret;
   },
+  getCurrentList() {
+    const listId = this.getCurrentListId();
+    let ret = null;
+    if (listId) {
+      ret = ReactiveCache.getList(listId);
+    }
+    return ret;
+  },
   getPopupCard() {
     const cardId = Utils.getPopupCardId();
     const ret = ReactiveCache.getCard(cardId);