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 { 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();

@ -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
}
}
});

Loading…
Cancel
Save