2019-04-26 19:09:08 +00:00
|
|
|
/**
|
|
|
|
* Module for Tray functions.
|
|
|
|
*/
|
|
|
|
|
2020-05-12 16:55:56 +00:00
|
|
|
const { BrowserWindow, Tray } = require('electron')
|
2019-04-26 19:09:08 +00:00
|
|
|
|
2020-05-13 12:20:57 +00:00
|
|
|
const path = require('path');
|
|
|
|
|
2019-04-26 19:09:08 +00:00
|
|
|
let trayServiceWindow = null
|
|
|
|
let tray = null
|
|
|
|
|
|
|
|
let trayService = {}
|
|
|
|
|
|
|
|
trayService.initTray = (window) => {
|
|
|
|
trayServiceWindow = window
|
2020-05-13 12:20:57 +00:00
|
|
|
let iconPath = path.join(__dirname, '/../resources/images/icon.png')
|
2019-04-26 19:09:08 +00:00
|
|
|
tray = new Tray(iconPath)
|
|
|
|
tray.setToolTip('Chimeverse')
|
|
|
|
tray.on('click', function() {
|
2020-05-12 16:55:56 +00:00
|
|
|
// Sent open-related-chat event only on click
|
|
|
|
let activeWindow = BrowserWindow.getAllWindows()[0]
|
|
|
|
activeWindow.webContents.send('open-unread-chat')
|
2019-04-26 19:09:08 +00:00
|
|
|
trayService.hideEnvelope()
|
|
|
|
trayServiceWindow.show()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
trayService.showEnvelope = () => {
|
2020-05-13 12:20:57 +00:00
|
|
|
tray.setImage(path.join(__dirname, '/../resources/images/envelope.png'))
|
2019-04-26 19:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trayService.hideEnvelope = () => {
|
2020-05-13 12:20:57 +00:00
|
|
|
tray.setImage(path.join(__dirname, '/../resources/images/icon.png'))
|
2019-04-26 19:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = trayService
|