diff --git a/src/index.js b/src/index.js index 7cde96af..a3790325 100644 --- a/src/index.js +++ b/src/index.js @@ -597,6 +597,15 @@ const windowState = new Store({ }, }); +// Get icon image +let iconImage = nativeImage.createFromPath( + path.join( + __dirname, + "/windows/otherAssets/icon" + + (process.platform === "linux" ? ".png" : ".ico") + ) +); + // Get tray icon image let trayIconImage = nativeImage.createFromPath( path.join( @@ -606,6 +615,11 @@ let trayIconImage = nativeImage.createFromPath( ) ); +// Get tray notification image +let trayIconNotificationImage = nativeImage.createFromPath( + path.join(__dirname, "/windows/otherAssets/tray-notification.png") +); + // Sets the default settings let settings = new Store({ name: "settings", @@ -653,13 +667,7 @@ if (!singleInstanceLock) { // Set main window background color backgroundColor: "#282C34", // Set main window icon - icon: nativeImage.createFromPath( - path.join( - __dirname, - "/windows/otherAssets/icon" + - (process.platform === "linux" ? ".png" : ".ico") - ) - ), + icon: iconImage, webPreferences: { // Enable tag for embedding WhatsApp webviewTag: true, @@ -891,45 +899,56 @@ if (!singleInstanceLock) { ipcMain.on("message-indicator", (e, messageCount) => { if ( - messageCount > 0 && - messageCount !== null && - messageCount !== undefined + settings + .get("settings") + .find((setting) => setting.id === "notificationBadge").value ) { - switch (process.platform) { - case "darwin": - app.dock.setBadge("·"); - break; - case "win32": - if ( - settings - .get("settings") - .find((setting) => setting.id === "notificationCountInTray") - .value - ) { - trayBadge.generate(messageCount).then((imgDataUrl) => { - const generatedImage = nativeImage.createFromDataURL( - imgDataUrl - ); - if (trayIcon) trayIcon.setImage(generatedImage); - }); - } - break; - default: - break; - } - } else { - switch (process.platform) { - case "darwin": - app.dock.setBadge(""); - break; - default: - if (trayIcon) trayIcon.setImage(trayIconImage); - break; + if ( + messageCount > 0 && + messageCount !== null && + messageCount !== undefined + ) { + switch (process.platform) { + case "darwin": + app.dock.setBadge("·"); + break; + case "win32": + if ( + settings + .get("settings") + .find((setting) => setting.id === "notificationCountInTray") + .value + ) { + trayBadge.generate(messageCount).then((imgDataUrl) => { + const generatedImage = nativeImage.createFromDataURL( + imgDataUrl + ); + if (trayIcon) trayIcon.setImage(generatedImage); + }); + } + break; + default: + if (trayIcon) trayIcon.setImage(trayIconNotificationImage); + + mainWindow.setIcon(trayIconNotificationImage); + break; + } + } else { + switch (process.platform) { + case "darwin": + app.dock.setBadge(""); + break; + default: + if (trayIcon) trayIcon.setImage(trayIconImage); + + mainWindow.setIcon(iconImage); + break; + } } - } - if (process.platform === "win32") { - mainWindow.webContents.send("message-indicator", messageCount); + if (process.platform === "win32") { + mainWindow.webContents.send("message-indicator", messageCount); + } } }); }); diff --git a/src/js/defaultSettings.js b/src/js/defaultSettings.js index aa12bc85..f2bf7cb0 100644 --- a/src/js/defaultSettings.js +++ b/src/js/defaultSettings.js @@ -29,7 +29,7 @@ const defaultSettings = [ value: true, name: "Custom Titlebar", description: - "If you are having any issues with the custom titlebar, you can disable it using this setting. NOTE: This setting requires you to restart the whole app for changes to apply.", + "If you are having any issues with the custom titlebar, you can disable it using this setting. NOTE: Requires restart of the application to apply.", id: "customTitlebar", }, { @@ -46,6 +46,13 @@ const defaultSettings = [ "When enabled, Altus will remember what tab was last active so when you re-open the app it will focus the tab which was last active.", id: "rememberActiveTab", }, + { + value: true, + name: "Show Notification Badge", + description: + "When enabled, Altus will show the notification badge on the dock and tray. NOTE: Requires restart of the application to apply.", + id: "notificationBadge", + }, { value: true, name: "Show Notification Count In Tray Icon (Windows)", diff --git a/src/windows/otherAssets/tray-notification.png b/src/windows/otherAssets/tray-notification.png new file mode 100644 index 00000000..0dad3e2f Binary files /dev/null and b/src/windows/otherAssets/tray-notification.png differ