feat: adds notifications dot on the badge icon for Mac

pull/3216/head
Emily 1 year ago
parent 62300dcb5b
commit 6dd261567d

@ -14,8 +14,6 @@ import { syncConfigurationIfNeeded } from '../../session/utils/sync/syncUtils';
import { clearSearch } from '../../state/ducks/search'; import { clearSearch } from '../../state/ducks/search';
import { resetLeftOverlayMode, SectionType, showLeftPaneSection } from '../../state/ducks/section'; import { resetLeftOverlayMode, SectionType, showLeftPaneSection } from '../../state/ducks/section';
import { import {
_getGlobalUnreadCount,
_getSortedConversations,
getGlobalUnreadMessageCount, getGlobalUnreadMessageCount,
getOurPrimaryConversation, getOurPrimaryConversation,
} from '../../state/selectors/conversations'; } from '../../state/selectors/conversations';
@ -219,11 +217,11 @@ const doAppStartUp = async () => {
}, 20000); }, 20000);
}; };
global.setTimeout(() => { // global.setTimeout(() => {
const unreadMessageCount = useSelector(getGlobalUnreadMessageCount); // const unreadMessageCount = useSelector(getGlobalUnreadMessageCount);
// Send the calculated count to the main process to update the badge count // // Send the calculated count to the main process to update the badge count
ipcRenderer.send('update-badge-count', unreadMessageCount); // ipcRenderer.send('update-badge-count', unreadMessageCount);
}, 3000); // }, 3000);
/** /**
* ActionsPanel is the far left banner (not the left pane). * ActionsPanel is the far left banner (not the left pane).
@ -247,6 +245,16 @@ export const ActionsPanel = () => {
return () => clearTimeout(timeout); 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); useInterval(cleanUpOldDecryptedMedias, startCleanUpMedia ? cleanUpMediasInterval : null);
useFetchLatestReleaseFromFileServer(); useFetchLatestReleaseFromFileServer();

@ -1025,11 +1025,13 @@ ipc.on('get-start-in-tray', event => {
}); });
ipcMain.on('update-badge-count', (_event, count) => { ipcMain.on('update-badge-count', (_event, count) => {
if (app.isReady()) {
if (count === 0) { if (count === 0) {
app.setBadgeCount(0); // Clear the badge app.setBadgeCount(0); // Clear the badge
} else { } else {
app.setBadgeCount(count); // Set the badge count app.setBadgeCount(count); // Set the badge count
} }
}
}); });
ipc.on('get-opengroup-pruning', event => { ipc.on('get-opengroup-pruning', event => {

Loading…
Cancel
Save