diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 27690be501..a97fb5b919 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -76,5 +76,13 @@ "bring_all_to_front": "Bring All to Front", "label": "Window", "zoom": "Zoom" + }, + "icon_overlay": { + "description_notifications": { + "one": "You have %(count)s unread notification.", + "other": "You have %(count)s unread notifications." + }, + "description_error": "Error" } + } diff --git a/src/ipc.ts b/src/ipc.ts index 40aaa63398..6050553af2 100644 --- a/src/ipc.ts +++ b/src/ipc.ts @@ -12,21 +12,6 @@ import { randomArray } from "./utils.js"; import { getDisplayMediaCallback, setDisplayMediaCallback } from "./displayMediaCallback.js"; import Store, { clearDataAndRelaunch } from "./store.js"; -ipcMain.on( - "setBadgeCount", - function (_ev: IpcMainEvent, count: number, imageBuffer?: Buffer, imageBufferDescription?: string): void { - if (process.platform !== "win32") { - // only set badgeCount on Mac/Linux, the docs say that only those platforms support it but turns out Electron - // has some Windows support too, and in some Windows environments this leads to two badges rendering atop - // each other. See https://github.com/vector-im/element-web/issues/16942 - app.badgeCount = count; - } - if (count === 0) { - global.mainWindow?.flashFrame(false); - } - }, -); - let focusHandlerAttached = false; ipcMain.on("loudNotification", function (): void { if (process.platform === "win32" || process.platform === "linux") { diff --git a/src/tray.ts b/src/tray.ts index 72ceeaa5d5..6df764ecd9 100644 --- a/src/tray.ts +++ b/src/tray.ts @@ -68,45 +68,25 @@ export function create(config: IConfig): void { initApplicationMenu(); trayIcon.on("click", toggleWin); - if (process.platform === "win32") { - // We only use setOverlayIcon on Windows as it's only supported on that platform, but has good support - // from all the Windows variants we support. - // https://www.electronjs.org/docs/latest/api/browser-window#winsetoverlayiconoverlay-description-windows - ipcMain.on( - "setBadgeCount", - function (_ev: IpcMainEvent, count: number, imageBuffer?: Buffer, imageBufferDescription?: string): void { - if (imageBuffer && imageBufferDescription !== undefined) { - global.mainWindow?.setOverlayIcon( - nativeImage.createFromBuffer(Buffer.from(imageBuffer)), - imageBufferDescription, - ); - } else { - global.mainWindow?.setOverlayIcon(null, ""); - } - }, - ); - } else { - // For other platforms, we instead update the application icon when the favicon changes. - let lastFavicon: string | null = null; - global.mainWindow?.webContents.on("page-favicon-updated", async function (ev, favicons) { - if (!favicons || favicons.length <= 0 || !favicons[0].startsWith("data:")) { - if (lastFavicon !== null) { - global.mainWindow?.setIcon(defaultIcon); - trayIcon?.setImage(defaultIcon); - lastFavicon = null; - } - return; + let lastFavicon: string | null = null; + global.mainWindow?.webContents.on("page-favicon-updated", async function (ev, favicons) { + if (!favicons || favicons.length <= 0 || !favicons[0].startsWith("data:")) { + if (lastFavicon !== null) { + global.mainWindow?.setIcon(defaultIcon); + trayIcon?.setImage(defaultIcon); + lastFavicon = null; } + return; + } - // No need to change, shortcut - if (favicons[0] === lastFavicon) return; - lastFavicon = favicons[0]; + // No need to change, shortcut + if (favicons[0] === lastFavicon) return; + lastFavicon = favicons[0]; - const newFavicon = nativeImage.createFromDataURL(favicons[0]); - trayIcon?.setImage(newFavicon); - global.mainWindow?.setIcon(newFavicon); - }); - } + const newFavicon = nativeImage.createFromDataURL(favicons[0]); + trayIcon?.setImage(newFavicon); + global.mainWindow?.setIcon(newFavicon); + }); global.mainWindow?.webContents.on("page-title-updated", function (ev, title) { trayIcon?.setToolTip(title);