diff --git a/main.js b/main.js index 8d71964bd..9e582d614 100644 --- a/main.js +++ b/main.js @@ -43,7 +43,15 @@ app.on('ready', function() { ]); trayIcon.setToolTip('GitHub Notifications on your menu bar.'); - trayIcon.setContextMenu(trayMenu); + + if (isLinux) { + trayIcon.setContextMenu(trayMenu); + } else { + trayIcon.on('click', () => { + appWindow.isFocused() ? appWindow.hide() : appWindow.show(); + }); + } + return trayIcon; } diff --git a/src/js/__mocks__/electron.js b/src/js/__mocks__/electron.js index df4d53a37..63da587c1 100644 --- a/src/js/__mocks__/electron.js +++ b/src/js/__mocks__/electron.js @@ -34,6 +34,7 @@ const browserWindow = { }, on: () => {}, close: jest.fn(), + hide: jest.fn(), destroy: jest.fn(), }; @@ -48,6 +49,7 @@ module.exports = { app: { getVersion: () => '0.0.1', }, + getCurrentWindow: jest.fn(() => browserWindow), }, ipcRenderer: { send: jest.fn(), diff --git a/src/js/utils/notifications.js b/src/js/utils/notifications.js index 3cf5f4db0..c7bf899df 100644 --- a/src/js/utils/notifications.js +++ b/src/js/utils/notifications.js @@ -1,3 +1,5 @@ +const { remote } = require('electron'); + import { reOpenWindow, openExternalLink } from '../utils/comms'; import { generateGitHubWebUrl } from '../utils/helpers'; @@ -55,7 +57,10 @@ export default { nativeNotification.onclick = function() { if (count === 1) { + const appWindow = remote.getCurrentWindow(); const url = generateGitHubWebUrl(notificationUrl); + + appWindow.hide(); openExternalLink(url); } else { reOpenWindow();