diff --git a/desktop/main.js b/desktop/main.js index 7d4622f..62476b4 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -8,7 +8,7 @@ // - external links open in the user's browser, not inside the app // // Server origin is configurable so the same build works against prod or a dev server. -const { app, BrowserWindow, session, desktopCapturer, shell, Menu, ipcMain } = require('electron'); +const { app, BrowserWindow, session, desktopCapturer, shell, Menu, ipcMain, nativeImage } = require('electron'); const path = require('path'); // Renderer asks (via preload) to raise the window — e.g. when an OS notification is clicked. @@ -19,6 +19,18 @@ ipcMain.on('focus-window', () => { win.focus(); }); +// Unread badge on the taskbar icon. The renderer computes the count (chats with unread) and +// draws the badge image (it has a canvas); Windows shows it via an overlay icon, macOS/Linux +// via the dock badge count. +ipcMain.on('set-unread', (_e, { count, dataUrl } = {}) => { + try { + if (typeof app.setBadgeCount === 'function') app.setBadgeCount(count || 0); // macOS/Linux dock + if (!win) return; + const overlay = (count > 0 && dataUrl) ? nativeImage.createFromDataURL(dataUrl) : null; + win.setOverlayIcon(overlay, count > 0 ? (count + ' unread chats') : ''); // Windows taskbar + } catch (_) {} +}); + const SERVER_URL = (process.env.SERVER_URL || 'https://remote.bizgaze.com').replace(/\/+$/, ''); let win; diff --git a/desktop/preload.js b/desktop/preload.js index a66424e..4aaa106 100644 --- a/desktop/preload.js +++ b/desktop/preload.js @@ -10,4 +10,7 @@ contextBridge.exposeInMainWorld('bizConnectNative', Object.freeze({ // Bring the app window to the foreground (e.g. when a notification is clicked) — the web // Notification's window.focus() can't raise an Electron window; the main process must. focusApp: () => ipcRenderer.send('focus-window'), + // Show the unread-chat count as a badge on the taskbar icon. count=number of chats with + // unread; dataUrl=a small PNG badge the renderer drew (null to clear). + setUnread: (count, dataUrl) => ipcRenderer.send('set-unread', { count, dataUrl }), })); diff --git a/server/public/home.html b/server/public/home.html index c1628bc..153011a 100644 --- a/server/public/home.html +++ b/server/public/home.html @@ -721,7 +721,7 @@
- +