converse-desktop/modules/tray-service.js

37 lines
936 B
JavaScript
Raw Normal View History

/**
* Module for Tray functions.
*/
2020-05-12 16:55:56 +00:00
const { BrowserWindow, Tray } = require('electron')
2020-05-13 12:20:57 +00:00
const path = require('path');
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')
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')
trayService.hideEnvelope()
trayServiceWindow.show()
})
}
trayService.showEnvelope = () => {
2020-05-13 12:20:57 +00:00
tray.setImage(path.join(__dirname, '/../resources/images/envelope.png'))
}
trayService.hideEnvelope = () => {
2020-05-13 12:20:57 +00:00
tray.setImage(path.join(__dirname, '/../resources/images/icon.png'))
}
module.exports = trayService