diff --git a/modules/tray-service.js b/modules/tray-service.js index 7b8f39f..ad65f86 100644 --- a/modules/tray-service.js +++ b/modules/tray-service.js @@ -2,20 +2,17 @@ * Module for Tray functions. */ -const { BrowserWindow, Tray } = require('electron') +const { Tray } = require('electron') const path = require('path') -let trayServiceWindow = null let tray = null const trayService = {} const getTrayServiceIcon = (iconName = 'icon') => { - let iconImage = '' - if (process.platform === 'darwin') { - iconImage = iconName - } else if (process.platform === 'win32') { + let iconImage; + if (process.platform === 'darwin' || process.platform === 'win32') { iconImage = iconName+'-16x16' } else { iconImage = iconName+'-48x48' @@ -24,16 +21,13 @@ const getTrayServiceIcon = (iconName = 'icon') => { } trayService.initTray = (window) => { - trayServiceWindow = window const iconPath = getTrayServiceIcon() tray = new Tray(iconPath) tray.setToolTip('Converse Desktop') tray.on('click', function() { - // Sent open-related-chat event only on click - const activeWindow = BrowserWindow.getAllWindows()[0] - activeWindow.webContents.send('open-unread-chat') + window.webContents.send('open-unread-chat') trayService.hideEnvelope() - trayServiceWindow.show() + window.show() }) }