diff --git a/ts/components/leftpane/ActionsPanel.tsx b/ts/components/leftpane/ActionsPanel.tsx index 3c6a535da..1a8d8cb31 100644 --- a/ts/components/leftpane/ActionsPanel.tsx +++ b/ts/components/leftpane/ActionsPanel.tsx @@ -14,8 +14,6 @@ import { syncConfigurationIfNeeded } from '../../session/utils/sync/syncUtils'; import { clearSearch } from '../../state/ducks/search'; import { resetLeftOverlayMode, SectionType, showLeftPaneSection } from '../../state/ducks/section'; import { - _getGlobalUnreadCount, - _getSortedConversations, getGlobalUnreadMessageCount, getOurPrimaryConversation, } from '../../state/selectors/conversations'; @@ -219,11 +217,11 @@ const doAppStartUp = async () => { }, 20000); }; -global.setTimeout(() => { - const unreadMessageCount = useSelector(getGlobalUnreadMessageCount); - // Send the calculated count to the main process to update the badge count - ipcRenderer.send('update-badge-count', unreadMessageCount); -}, 3000); +// global.setTimeout(() => { +// const unreadMessageCount = useSelector(getGlobalUnreadMessageCount); +// // Send the calculated count to the main process to update the badge count +// ipcRenderer.send('update-badge-count', unreadMessageCount); +// }, 3000); /** * ActionsPanel is the far left banner (not the left pane). @@ -247,6 +245,16 @@ export const ActionsPanel = () => { return () => clearTimeout(timeout); }, []); + const globalUnreadMessageCount = useSelector(getGlobalUnreadMessageCount); + 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]); + useInterval(cleanUpOldDecryptedMedias, startCleanUpMedia ? cleanUpMediasInterval : null); useFetchLatestReleaseFromFileServer(); diff --git a/ts/mains/main_node.ts b/ts/mains/main_node.ts index 80fb672db..a3c018bda 100644 --- a/ts/mains/main_node.ts +++ b/ts/mains/main_node.ts @@ -1025,10 +1025,12 @@ ipc.on('get-start-in-tray', event => { }); ipcMain.on('update-badge-count', (_event, count) => { - if (count === 0) { - app.setBadgeCount(0); // Clear the badge - } else { - app.setBadgeCount(count); // Set the badge count + if (app.isReady()) { + if (count === 0) { + app.setBadgeCount(0); // Clear the badge + } else { + app.setBadgeCount(count); // Set the badge count + } } });