From 131959e050126598bd682cf3d59eed464d410544 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Sun, 11 Dec 2022 12:19:01 +0100 Subject: [PATCH] minicard.js, reduce this.data().board() call --- client/components/cards/minicard.js | 52 +++++++++++++++++------------ 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/client/components/cards/minicard.js b/client/components/cards/minicard.js index d06eb30fb..587534f6e 100644 --- a/client/components/cards/minicard.js +++ b/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