Unread icon fix, do not create panel icon on macOS ATM.
This commit is contained in:
parent
f1ed198d59
commit
97353ead0f
19
main.js
19
main.js
@ -43,7 +43,8 @@ function createWindow() {
|
||||
|
||||
mainWindow.setIcon(normalIcon);
|
||||
|
||||
// Tray icon.
|
||||
// Tray icon. Do not create it on macOS.
|
||||
if (app.platform != "darwin") {
|
||||
tray = new Tray(normalIcon);
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: 'Open Yandex.Mail window', type: 'normal', click: showHideMainWindow },
|
||||
@ -57,6 +58,8 @@ function createWindow() {
|
||||
showHideMainWindow(null, mainWindow, null);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
mainWindow.Notification = function (title, options) {
|
||||
options.icon = unreadIcon;
|
||||
notification = new Notification(title, options);
|
||||
@ -82,14 +85,22 @@ app.on('activate', function () {
|
||||
}
|
||||
});
|
||||
|
||||
ipc.on("has-unread", function () {
|
||||
ipc.on("has-unread", function (event, count) {
|
||||
mainWindow.setIcon(unreadIcon);
|
||||
if (app.platform == "darwin") {
|
||||
app.setBadgeCount(count);
|
||||
} else {
|
||||
tray.setImage(unreadIcon);
|
||||
}
|
||||
});
|
||||
|
||||
ipc.on("has-no-unread", function () {
|
||||
ipc.on("has-no-unread", function (event, count) {
|
||||
mainWindow.setIcon(normalIcon);
|
||||
tray.setImage(normalIcon);
|
||||
if (app.platform == "darwin") {
|
||||
app.setBadgeCount(count);
|
||||
} else {
|
||||
tray.setImage(unreadIcon);
|
||||
}
|
||||
})
|
||||
|
||||
function showHideMainWindow() {
|
||||
|
@ -28,7 +28,8 @@
|
||||
"productName": "Yandex.Mail Desktop",
|
||||
"copyright": "Copyright (c) 2019, Stanislav N. aka pztrn",
|
||||
"mac": {
|
||||
"category": "name.pztrn.yandexmail-desktop"
|
||||
"category": "name.pztrn.yandexmail-desktop",
|
||||
"icon": "./assets/icons/icon.png"
|
||||
},
|
||||
"linux": {
|
||||
"category": "Internet",
|
||||
|
@ -3,8 +3,8 @@ var ipc = require("electron").ipcRenderer;
|
||||
|
||||
function checkForUnreads() {
|
||||
unread = parseInt(document.title.split(" ")[0]);
|
||||
if (unread > 0) {
|
||||
ipc.send('has-unread');
|
||||
if (typeof (unread) != NaN && unread > 0) {
|
||||
ipc.send('has-unread', unread);
|
||||
} else {
|
||||
ipc.send('has-no-unread');
|
||||
};
|
||||
|
Reference in New Issue
Block a user