From 1d33fc6f6e46f3a05eb1c90102fe912e4e4a972d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20de=20Saint-Exup=C3=A9ry?= Date: Thu, 25 Aug 2016 10:54:47 +0200 Subject: [PATCH] Show or restore if minimized --- src/main/menus/tray.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/menus/tray.js b/src/main/menus/tray.js index f5fedc68..2ac3ef4f 100644 --- a/src/main/menus/tray.js +++ b/src/main/menus/tray.js @@ -12,12 +12,7 @@ function createTemplate(mainWindow, config) { return { label: team.name, click: (item, focusedWindow) => { - if (mainWindow.isMinimized()) { - mainWindow.restore(); - } - else { - mainWindow.show(); - } + showOrRestore(mainWindow); mainWindow.webContents.send('switch-tab', i); if (process.platform === 'darwin') { @@ -32,7 +27,7 @@ function createTemplate(mainWindow, config) { label: 'Settings', click: () => { mainWindow.loadURL('file://' + __dirname + '/browser/settings.html'); - mainWindow.show(); + showOrRestore(mainWindow); } }, { type: 'separator' @@ -47,6 +42,10 @@ var createMenu = function(mainWindow, config) { return Menu.buildFromTemplate(createTemplate(mainWindow, config)); }; +function showOrRestore(window) { + window.isMinimized() ? window.restore() : window.show() +} + module.exports = { createMenu: createMenu };