Skip to content

Commit 3f07186

Browse files
authored
Merge pull request #300 from manosim/tray-icon
Tray Icon, toggle gitify on click
2 parents 7557924 + 629f13d commit 3f07186

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

main.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ app.on('ready', function() {
4343
]);
4444

4545
trayIcon.setToolTip('GitHub Notifications on your menu bar.');
46-
trayIcon.setContextMenu(trayMenu);
46+
47+
if (isLinux) {
48+
trayIcon.setContextMenu(trayMenu);
49+
} else {
50+
trayIcon.on('click', () => {
51+
appWindow.isFocused() ? appWindow.hide() : appWindow.show();
52+
});
53+
}
54+
4755
return trayIcon;
4856
}
4957

src/js/__mocks__/electron.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const browserWindow = {
3434
},
3535
on: () => {},
3636
close: jest.fn(),
37+
hide: jest.fn(),
3738
destroy: jest.fn(),
3839
};
3940

@@ -48,6 +49,7 @@ module.exports = {
4849
app: {
4950
getVersion: () => '0.0.1',
5051
},
52+
getCurrentWindow: jest.fn(() => browserWindow),
5153
},
5254
ipcRenderer: {
5355
send: jest.fn(),

src/js/utils/notifications.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { remote } = require('electron');
2+
13
import { reOpenWindow, openExternalLink } from '../utils/comms';
24
import { generateGitHubWebUrl } from '../utils/helpers';
35

@@ -55,7 +57,10 @@ export default {
5557

5658
nativeNotification.onclick = function() {
5759
if (count === 1) {
60+
const appWindow = remote.getCurrentWindow();
5861
const url = generateGitHubWebUrl(notificationUrl);
62+
63+
appWindow.hide();
5964
openExternalLink(url);
6065
} else {
6166
reOpenWindow();

0 commit comments

Comments
 (0)