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