mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-05 12:16:53 +02:00
Update with a proper comment
This commit is contained in:
parent
92a7da38ea
commit
b13f3ba1bd
@ -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"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
15
src/ipc.ts
15
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") {
|
||||
|
||||
52
src/tray.ts
52
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user