Skip to content
This repository was archived by the owner on Aug 6, 2021. It is now read-only.

Commit 3a5efcd

Browse files
committed
Only display tray icon when required and updated npm version
1 parent be14d94 commit 3a5efcd

File tree

2 files changed

+39
-45
lines changed

2 files changed

+39
-45
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "A desktop implementation for the bunq API",
44
"productName": "BunqDesktop",
55
"homepage": "https://bunqdesktop.com/",
6-
"version": "0.8.0",
6+
"version": "0.8.1",
77
"author": {
88
"name": "BunqCommunity",
99
"email": "[email protected]"

src/background.js

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -79,53 +79,47 @@ app.on("ready", () => {
7979
path.join(__dirname, "../app/images/32x32.png")
8080
);
8181

82-
// setup the tray handler
83-
const tray = new Tray(trayIcon);
84-
const contextMenu = Menu.buildFromTemplate([
85-
{
86-
label: "Dashboard",
87-
click: () => changePage(mainWindow, "/")
88-
},
89-
{
90-
label: "Pay",
91-
click: () => changePage(mainWindow, "/pay")
92-
},
93-
{
94-
label: "Request",
95-
click: () => changePage(mainWindow, "/request")
96-
},
97-
{
98-
label: "Cards",
99-
click: () => changePage(mainWindow, "/card")
100-
},
101-
{ type: "separator" },
102-
{
103-
label: "Quit",
104-
click: () => app.quit()
105-
}
106-
]);
107-
tray.setContextMenu(contextMenu);
108-
tray.setToolTip("BunqDesktop");
109-
110-
// Event handlers
111-
tray.on("click", () => {
112-
// show app on single click
113-
if (!mainWindow.isVisible()) mainWindow.show();
114-
});
115-
tray.on("double-click", () => {
116-
// hide app on double click
117-
if (mainWindow.isVisible()) mainWindow.hide();
118-
});
82+
const createTrayIcon = () => {
83+
// setup the tray handler
84+
const tray = new Tray(trayIcon);
85+
const contextMenu = Menu.buildFromTemplate([
86+
{
87+
label: "Dashboard",
88+
click: () => changePage(mainWindow, "/")
89+
},
90+
{
91+
label: "Pay",
92+
click: () => changePage(mainWindow, "/pay")
93+
},
94+
{
95+
label: "Request",
96+
click: () => changePage(mainWindow, "/request")
97+
},
98+
{
99+
label: "Cards",
100+
click: () => changePage(mainWindow, "/card")
101+
},
102+
{ type: "separator" },
103+
{
104+
label: "Quit",
105+
click: () => app.quit()
106+
}
107+
]);
108+
tray.setContextMenu(contextMenu);
109+
tray.setToolTip("BunqDesktop");
110+
111+
// Event handlers
112+
tray.on("click", () => {
113+
// show app on single click
114+
if (!mainWindow.isVisible()) mainWindow.show();
115+
tray.destroy();
116+
});
117+
}
119118

120-
mainWindow.on("show", () => {
121-
tray.setHighlightMode("always");
122-
});
123-
mainWindow.on("hide", () => {
124-
tray.setHighlightMode("never");
125-
});
126119
mainWindow.on("minimize", function(event) {
127-
const minimizeToTray = !!settings.get("MINIMIZE_TO_TRAY_LOCATION");
120+
const minimizeToTray = !!settings.get("MINIMIZE_TO_TRAY");
128121
if (minimizeToTray) {
122+
createTrayIcon();
129123
event.preventDefault();
130124
mainWindow.hide();
131125
}

0 commit comments

Comments
 (0)