From 21b8b9f35b35d5ca689e142abbcd51e4876db138 Mon Sep 17 00:00:00 2001 From: Brice-W Date: Tue, 6 Jul 2021 17:21:43 +1000 Subject: [PATCH] memory optimization --- ts/state/selectors/conversations.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index f580406f3..869be2742 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -223,6 +223,10 @@ export const getUnreadMessageCount = createSelector(getLeftPaneLists, (state): n }); export const getNumberOfPinnedConversations = createSelector(getConversations, (state): number => { - const values = Object.values(state.conversationLookup); - return values.filter(conversation => conversation.isPinned).length; + let count = 0; + for (let key in state.conversationLookup) { + let value = state.conversationLookup[key]; + if (value.isPinned) count++; + } + return count; });