feat(desktop): unread-chat count badge on the taskbar icon
Mirrors the rail's unread-chat count onto the Windows taskbar icon (overlay) and the macOS/Linux dock badge. updateRailUnread() draws a small red count badge on a canvas and hands it to the shell via bizConnectNative.setUnread(count, dataUrl); main sets it with win.setOverlayIcon + app.setBadgeCount. Clears at 0, shows 99+ past 99. No-op in a browser/mobile. (home.html build batch17) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+13
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user