diff --git a/app/renderer/js/tray.ts b/app/renderer/js/tray.ts index 289090aa4..e7d9220ef 100644 --- a/app/renderer/js/tray.ts +++ b/app/renderer/js/tray.ts @@ -17,16 +17,37 @@ let tray: ElectronTray | null = null; const appIcon = path.join(publicPath, "resources/tray/tray"); const iconPath = (): string => { - if (process.platform === "linux") { - return appIcon + "linux.png"; - } + switch (process.platform) { + case "darwin": { + return appIcon + "macOSTemplate.png"; + } + + case "win32": { + return appIcon + "win.ico"; + } - return ( - appIcon + (process.platform === "win32" ? "win.ico" : "macOSTemplate.png") - ); + default: { + return appIcon + "linux.png"; + } + } }; -const winUnreadTrayIconPath = (): string => appIcon + "unread.ico"; +const unreadTrayIconPath = (): string => { + switch (process.platform) { + case "darwin": { + return appIcon + "macOSUnreadTemplate.png"; + } + + case "win32": { + return appIcon + "unread.ico"; + } + + default: { + // Note this isn't used - see renderNativeImage() + return appIcon + "linux.png"; + } + } +}; let unread = 0; @@ -118,8 +139,8 @@ const renderCanvas = function (argument: number): HTMLCanvasElement { * @return the native image */ const renderNativeImage = function (argument: number): NativeImage { - if (process.platform === "win32") { - return nativeImage.createFromPath(winUnreadTrayIconPath()); + if (process.platform === "win32" || process.platform === "darwin") { + return nativeImage.createFromPath(unreadTrayIconPath()); } const canvas = renderCanvas(argument); @@ -197,18 +218,15 @@ export function initializeTray(serverManagerView: ServerManagerView) { return; } - // We don't want to create tray from unread messages on macOS since it already has dock badges. - if (process.platform === "linux" || process.platform === "win32") { - if (argument === 0) { - unread = argument; - tray.setImage(iconPath()); - tray.setToolTip("No unread messages"); - } else { - unread = argument; - const image = renderNativeImage(argument); - tray.setImage(image); - tray.setToolTip(`${argument} unread messages`); - } + // Update tray icon based on unread count + unread = argument; + if (unread === 0) { + tray.setImage(iconPath()); + tray.setToolTip("No unread messages"); + } else { + const image = renderNativeImage(argument); + tray.setImage(image); + tray.setToolTip(`${argument} unread messages`); } }); diff --git a/public/resources/tray/traymacOSTemplate.png b/public/resources/tray/traymacOSTemplate.png index 222de0636..8c3781e88 100644 Binary files a/public/resources/tray/traymacOSTemplate.png and b/public/resources/tray/traymacOSTemplate.png differ diff --git a/public/resources/tray/traymacOSTemplate@2x.png b/public/resources/tray/traymacOSTemplate@2x.png index 2400018a5..b97e3c6c1 100644 Binary files a/public/resources/tray/traymacOSTemplate@2x.png and b/public/resources/tray/traymacOSTemplate@2x.png differ diff --git a/public/resources/tray/traymacOSTemplate@3x.png b/public/resources/tray/traymacOSTemplate@3x.png index f234a51f3..0be30e5a4 100644 Binary files a/public/resources/tray/traymacOSTemplate@3x.png and b/public/resources/tray/traymacOSTemplate@3x.png differ diff --git a/public/resources/tray/traymacOSTemplate@4x.png b/public/resources/tray/traymacOSTemplate@4x.png index acb7b4b9e..c7082d2ff 100644 Binary files a/public/resources/tray/traymacOSTemplate@4x.png and b/public/resources/tray/traymacOSTemplate@4x.png differ diff --git a/public/resources/tray/traymacOSUnreadTemplate.png b/public/resources/tray/traymacOSUnreadTemplate.png new file mode 100644 index 000000000..e22b438ba Binary files /dev/null and b/public/resources/tray/traymacOSUnreadTemplate.png differ diff --git a/public/resources/tray/traymacOSUnreadTemplate@2x.png b/public/resources/tray/traymacOSUnreadTemplate@2x.png new file mode 100644 index 000000000..55a4afee8 Binary files /dev/null and b/public/resources/tray/traymacOSUnreadTemplate@2x.png differ diff --git a/public/resources/tray/traymacOSUnreadTemplate@3x.png b/public/resources/tray/traymacOSUnreadTemplate@3x.png new file mode 100644 index 000000000..c59a3530b Binary files /dev/null and b/public/resources/tray/traymacOSUnreadTemplate@3x.png differ diff --git a/public/resources/tray/traymacOSUnreadTemplate@4x.png b/public/resources/tray/traymacOSUnreadTemplate@4x.png new file mode 100644 index 000000000..4699ac672 Binary files /dev/null and b/public/resources/tray/traymacOSUnreadTemplate@4x.png differ