From 61c91be91ce642ea8778d71ad2f17e5fb2edda7d Mon Sep 17 00:00:00 2001 From: wafflesvsfrankie <92288602+burtonemily@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:48:27 +1100 Subject: [PATCH] fix: addresses feedback --- ts/components/leftpane/ActionsPanel.tsx | 15 ++++++++++----- ts/state/selectors/conversations.ts | 4 +--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index bba9b0bce..62635a602 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -5,6 +5,7 @@ import { useEffect, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useInterval from 'react-use/lib/useInterval'; import useTimeoutFn from 'react-use/lib/useTimeoutFn'; +import { useThrottleFn } from 'react-use'; import { Data } from '../../data/data'; import { getConversationController } from '../../session/conversations'; @@ -243,11 +244,15 @@ export const ActionsPanel = () => { const unreadToShow = globalUnreadMessageCount; // Reuse the unreadToShow from the global state to update the badge count - useEffect(() => { - if (unreadToShow !== undefined) { - ipcRenderer.send('update-badge-count', unreadToShow); - } - }, [unreadToShow]); + useThrottleFn( + () => { + if (unreadToShow !== undefined) { + ipcRenderer.send('update-badge-count', unreadToShow); + } + }, + 2000, + [] + ); useInterval(cleanUpOldDecryptedMedias, startCleanUpMedia ? cleanUpMediasInterval : null); diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 336d02ed4..5473c6e55 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -306,9 +306,7 @@ const _getContacts = ( }); }; -export const _getGlobalUnreadCount = ( - sortedConversations: Array -): number => { +const _getGlobalUnreadCount = (sortedConversations: Array): number => { let globalUnreadCount = 0; for (const conversation of sortedConversations) { // Blocked conversation are now only visible from the settings, not in the conversation list, so don't add it neither to the contacts list nor the conversation list