remove tray icon when process is shutdown

This commit is contained in:
Johannes Millan 2017-01-09 18:12:50 +01:00
parent 50a9993eb2
commit 5e8fdf724a
3 changed files with 14 additions and 4 deletions

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before After
Before After

View file

@ -1,7 +1,7 @@
const JiraApi = require('jira').JiraApi;
module.exports = (mainWindow, request) => {
console.log(request);
//console.log(request);
let config = request.config;
let apiMethod = request.apiMethod;
@ -12,7 +12,7 @@ module.exports = (mainWindow, request) => {
let jira = new JiraApi('https', config.host, config.port, config.userName, config.password, 'latest');
jira[apiMethod](...arguments, (error, res) => {
console.log('JIRA_RESPONSE', error, res);
//console.log('JIRA_RESPONSE', error, res);
mainWindow.webContents.send('JIRA_RESPONSE', {
error: error,

View file

@ -5,7 +5,7 @@ const powerSaveBlocker = require('electron').powerSaveBlocker;
const moment = require('moment');
const open = require('open');
const CONFIG = require('./CONFIG');
const IMAGE_FOLDER = __dirname + '/assets/img/';
const ICONS_FOLDER = __dirname + '/assets/icons/';
const idle = require('./idle');
const jira = require('./jira');
@ -77,7 +77,7 @@ app.on('window-all-closed', function () {
let appIcon = null;
app.on('ready', () => {
appIcon = new electron.Tray(IMAGE_FOLDER + 'ico.png');
appIcon = new electron.Tray(ICONS_FOLDER + 'tray-ico.png');
let contextMenu = electron.Menu.buildFromTemplate([
{
label: 'Show App', click: () => {
@ -92,6 +92,12 @@ app.on('ready', () => {
}
]);
appIcon.setContextMenu(contextMenu);
appIcon.on('click', () => {
console.log('I am here!');
mainWindow.show();
});
});
app.on('ready', () => {
@ -117,6 +123,10 @@ app.on('ready', () => {
setInterval(trackTimeFn, CONFIG.PING_INTERVAL);
});
app.on('before-quit', () => {
appIcon.destroy();
});
// listen to events from frontend
electron.ipcMain.on('SHUTDOWN', () => {
app.isQuiting = true;