|
| 1 | +import { ipcRenderer } from 'electron'; |
1 | 2 | import { debounce } from 'lodash';
|
2 | 3 | import { useEffect, useRef, useState } from 'react';
|
3 | 4 |
|
4 | 5 | import { useDispatch, useSelector } from 'react-redux';
|
5 | 6 | import useInterval from 'react-use/lib/useInterval';
|
6 | 7 | import useTimeoutFn from 'react-use/lib/useTimeoutFn';
|
| 8 | +import useThrottleFn from 'react-use/lib/useThrottleFn'; |
7 | 9 |
|
8 | 10 | import { Data } from '../../data/data';
|
9 | 11 | import { getConversationController } from '../../session/conversations';
|
@@ -37,18 +39,18 @@ import { LeftPaneSectionContainer } from './LeftPaneSectionContainer';
|
37 | 39 |
|
38 | 40 | import { SettingsKey } from '../../data/settings-key';
|
39 | 41 | import { useFetchLatestReleaseFromFileServer } from '../../hooks/useFetchLatestReleaseFromFileServer';
|
| 42 | +import { useHotkey } from '../../hooks/useHotkey'; |
40 | 43 | import {
|
41 | 44 | forceRefreshRandomSnodePool,
|
42 | 45 | getFreshSwarmFor,
|
43 | 46 | } from '../../session/apis/snode_api/snodePool';
|
44 | 47 | import { ConfigurationSync } from '../../session/utils/job_runners/jobs/ConfigurationSyncJob';
|
| 48 | +import { getIsModalVisble } from '../../state/selectors/modal'; |
45 | 49 | import { useIsDarkTheme } from '../../state/selectors/theme';
|
46 | 50 | import { switchThemeTo } from '../../themes/switchTheme';
|
47 | 51 | import { ReleasedFeatures } from '../../util/releaseFeature';
|
48 | 52 | import { getOppositeTheme } from '../../util/theme';
|
49 | 53 | import { SessionNotificationCount } from '../icon/SessionNotificationCount';
|
50 |
| -import { useHotkey } from '../../hooks/useHotkey'; |
51 |
| -import { getIsModalVisble } from '../../state/selectors/modal'; |
52 | 54 |
|
53 | 55 | const Section = (props: { type: SectionType }) => {
|
54 | 56 | const ourNumber = useSelector(getOurNumber);
|
@@ -238,6 +240,19 @@ export const ActionsPanel = () => {
|
238 | 240 | return () => clearTimeout(timeout);
|
239 | 241 | }, []);
|
240 | 242 |
|
| 243 | + const globalUnreadMessageCount = useSelector(getGlobalUnreadMessageCount); |
| 244 | + |
| 245 | + // Reuse the unreadToShow from the global state to update the badge count |
| 246 | + useThrottleFn( |
| 247 | + (unreadCount: number) => { |
| 248 | + if (globalUnreadMessageCount !== undefined) { |
| 249 | + ipcRenderer.send('update-badge-count', unreadCount); |
| 250 | + } |
| 251 | + }, |
| 252 | + 2000, |
| 253 | + [globalUnreadMessageCount] |
| 254 | + ); |
| 255 | + |
241 | 256 | useInterval(cleanUpOldDecryptedMedias, startCleanUpMedia ? cleanUpMediasInterval : null);
|
242 | 257 |
|
243 | 258 | useFetchLatestReleaseFromFileServer();
|
|
0 commit comments