Browse Source

minicard.js, reduce this.data().board() call

Martin Filser 2 years ago
parent
commit
131959e050
1 changed files with 30 additions and 22 deletions
  1. 30 22
      client/components/cards/minicard.js

+ 30 - 22
client/components/cards/minicard.js

@@ -37,37 +37,45 @@ BlazeComponent.extendComponent({
   },
 
   showCreator() {
-    if (this.data().board()) {
-      return (
-        this.data().board.allowsCreator === null ||
-        this.data().board().allowsCreator === undefined ||
-        this.data().board().allowsCreator
-      );
-      // return this.data().board().allowsCreator;
+    // cache "board" to reduce the mini-mongodb access
+    const board = this.data().board();
+    let ret = false;
+    if (board) {
+      ret =
+        board.allowsCreator === null ||
+        board.allowsCreator === undefined ||
+        board.allowsCreator
+      ;
     }
-    return false;
+    return ret;
   },
 
   showMembers() {
-    if (this.data().board()) {
-      return (
-        this.data().board.allowsMembers === null ||
-        this.data().board().allowsMembers === undefined ||
-        this.data().board().allowsMembers
-      );
+    // cache "board" to reduce the mini-mongodb access
+    const board = this.data().board();
+    let ret = false;
+    if (board) {
+      ret =
+        board.allowsMembers === null ||
+        board.allowsMembers === undefined ||
+        board.allowsMembers
+      ;
     }
-    return false;
+    return ret;
   },
 
   showAssignee() {
-    if (this.data().board()) {
-      return (
-        this.data().board.allowsAssignee === null ||
-        this.data().board().allowsAssignee === undefined ||
-        this.data().board().allowsAssignee
-      );
+    // cache "board" to reduce the mini-mongodb access
+    const board = this.data().board();
+    let ret = false;
+    if (board) {
+      ret =
+        board.allowsAssignee === null ||
+        board.allowsAssignee === undefined ||
+        board.allowsAssigne
+      ;
     }
-    return false;
+    return ret;
   },
 
   /** opens the card label popup only if clicked onto a label