From 4824dda5d52565deb5cd6ef4b51d2d742677a154 Mon Sep 17 00:00:00 2001 From: TC Date: Mon, 27 Apr 2020 12:25:24 +0200 Subject: [PATCH] Move tray click callback in setUpTray --- index.js | 5 +---- tray.js | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 40ed1abc..d146d90a 100644 --- a/index.js +++ b/index.js @@ -166,10 +166,7 @@ app.on("activate", () => { app.on("ready", () => { setApplicationMenu(); mainWindow = createMainWindow(); - const tray = setUpTray(app, mainWindow); - tray.on("click", () => { - mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show(); - }); + setUpTray(app, mainWindow); if (!is.dev() && autoUpdate()) { autoUpdater.checkForUpdatesAndNotify(); diff --git a/tray.js b/tray.js index 3a32085e..dd79355c 100644 --- a/tray.js +++ b/tray.js @@ -23,6 +23,9 @@ module.exports.setUpTray = (app, win) => { tray = new Tray(trayIcon); tray.setToolTip("Youtube Music"); tray.setIgnoreDoubleClickEvents(true); + tray.on("click", () => { + win.isVisible() ? win.hide() : win.show(); + }); const trayMenu = Menu.buildFromTemplate([ { @@ -67,6 +70,4 @@ module.exports.setUpTray = (app, win) => { }, ]); tray.setContextMenu(trayMenu); - - return tray; };