parent
933c853395
commit
6f5cc13b2e
|
@ -2,20 +2,17 @@
|
||||||
* Module for Tray functions.
|
* Module for Tray functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { BrowserWindow, Tray } = require('electron')
|
const { Tray } = require('electron')
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
let trayServiceWindow = null
|
|
||||||
let tray = null
|
let tray = null
|
||||||
|
|
||||||
const trayService = {}
|
const trayService = {}
|
||||||
|
|
||||||
const getTrayServiceIcon = (iconName = 'icon') => {
|
const getTrayServiceIcon = (iconName = 'icon') => {
|
||||||
let iconImage = ''
|
let iconImage;
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin' || process.platform === 'win32') {
|
||||||
iconImage = iconName
|
|
||||||
} else if (process.platform === 'win32') {
|
|
||||||
iconImage = iconName+'-16x16'
|
iconImage = iconName+'-16x16'
|
||||||
} else {
|
} else {
|
||||||
iconImage = iconName+'-48x48'
|
iconImage = iconName+'-48x48'
|
||||||
|
@ -24,16 +21,13 @@ const getTrayServiceIcon = (iconName = 'icon') => {
|
||||||
}
|
}
|
||||||
|
|
||||||
trayService.initTray = (window) => {
|
trayService.initTray = (window) => {
|
||||||
trayServiceWindow = window
|
|
||||||
const iconPath = getTrayServiceIcon()
|
const iconPath = getTrayServiceIcon()
|
||||||
tray = new Tray(iconPath)
|
tray = new Tray(iconPath)
|
||||||
tray.setToolTip('Converse Desktop')
|
tray.setToolTip('Converse Desktop')
|
||||||
tray.on('click', function() {
|
tray.on('click', function() {
|
||||||
// Sent open-related-chat event only on click
|
window.webContents.send('open-unread-chat')
|
||||||
const activeWindow = BrowserWindow.getAllWindows()[0]
|
|
||||||
activeWindow.webContents.send('open-unread-chat')
|
|
||||||
trayService.hideEnvelope()
|
trayService.hideEnvelope()
|
||||||
trayServiceWindow.show()
|
window.show()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue