Don't create tray form unread counts on Windows + macOS

This commit is contained in:
akashnimare
2017-07-22 21:17:16 +05:30
parent d70783600d
commit 1d38ebdf05

View File

@@ -3,9 +3,9 @@ const path = require('path');
const electron = require('electron'); const electron = require('electron');
const {ipcRenderer, remote} = electron; const { ipcRenderer, remote } = electron;
const {Tray, Menu, nativeImage, BrowserWindow} = remote; const { Tray, Menu, nativeImage, BrowserWindow } = remote;
const APP_ICON = path.join(__dirname, '../../resources/tray', 'tray'); const APP_ICON = path.join(__dirname, '../../resources/tray', 'tray');
@@ -181,18 +181,19 @@ ipcRenderer.on('tray', (event, arg) => {
return; return;
} }
if (arg === 0) { if (process.platform === 'linux')
unread = arg; if (arg === 0) {
// Message Count // console.log("message count is zero."); unread = arg;
window.tray.setImage(iconPath()); // Message Count // console.log("message count is zero.");
window.tray.setToolTip('No unread messages'); window.tray.setImage(iconPath());
} else { window.tray.setToolTip('No unread messages');
unread = arg; } else {
renderNativeImage(arg).then(image => { unread = arg;
window.tray.setImage(image); renderNativeImage(arg).then(image => {
window.tray.setToolTip(arg + ' unread messages'); window.tray.setImage(image);
}); window.tray.setToolTip(arg + ' unread messages');
} });
}
}); });
function toggleTray() { function toggleTray() {
@@ -204,10 +205,12 @@ function toggleTray() {
ConfigUtil.setConfigItem('trayIcon', false); ConfigUtil.setConfigItem('trayIcon', false);
} else { } else {
createTray(); createTray();
renderNativeImage(unread).then(image => { if (process.platform === 'linux') {
window.tray.setImage(image); renderNativeImage(unread).then(image => {
window.tray.setToolTip(unread + ' unread messages'); window.tray.setImage(image);
}); window.tray.setToolTip(unread + ' unread messages');
});
}
ConfigUtil.setConfigItem('trayIcon', true); ConfigUtil.setConfigItem('trayIcon', true);
} }
} }