diff --git a/desktop/main.cjs b/desktop/main.cjs --- a/desktop/main.cjs +++ b/desktop/main.cjs @@ -116,6 +116,10 @@ } }); + ipcMain.on('set-badge', (event, value) => { + app.dock.setBadge(value?.toString() ?? ''); + }); + win.webContents.setWindowOpenHandler(({ url: openURL }) => { shell.openExternal(openURL); // Returning 'deny' prevents a new electron window from being created diff --git a/desktop/preload.cjs b/desktop/preload.cjs --- a/desktop/preload.cjs +++ b/desktop/preload.cjs @@ -8,6 +8,7 @@ }, clearHistory: () => ipcRenderer.send('clear-history'), doubleClickTopBar: () => ipcRenderer.send('double-click-top-bar'), + setBadge: value => ipcRenderer.send('set-badge', value), }; contextBridge.exposeInMainWorld('electronContextBridge', bridge); diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -269,6 +269,7 @@ const boundUnreadCount = useSelector(unreadCount); React.useEffect(() => { document.title = getTitle(boundUnreadCount); + electron?.setBadge(boundUnreadCount === 0 ? null : boundUnreadCount); }, [boundUnreadCount]); const dispatch = useDispatch(); diff --git a/web/electron.js b/web/electron.js --- a/web/electron.js +++ b/web/electron.js @@ -12,6 +12,7 @@ +onNavigate: OnNavigateListener => () => void, +clearHistory: () => void, +doubleClickTopBar: () => void, + +setBadge: (value: string | number | null) => void, } = typeof electronContextBridge === 'undefined' ? null : electronContextBridge; export default electron;