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

Commit

Permalink
Only display tray icon when required and updated npm version
Browse files Browse the repository at this point in the history
  • Loading branch information
Crecket committed Mar 25, 2018
1 parent be14d94 commit 3a5efcd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A desktop implementation for the bunq API",
"productName": "BunqDesktop",
"homepage": "https://bunqdesktop.com/",
"version": "0.8.0",
"version": "0.8.1",
"author": {
"name": "BunqCommunity",
"email": "bunqcommunity@gmail.com"
Expand Down
82 changes: 38 additions & 44 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,53 +79,47 @@ app.on("ready", () => {
path.join(__dirname, "../app/images/32x32.png")
);

// setup the tray handler
const tray = new Tray(trayIcon);
const contextMenu = Menu.buildFromTemplate([
{
label: "Dashboard",
click: () => changePage(mainWindow, "/")
},
{
label: "Pay",
click: () => changePage(mainWindow, "/pay")
},
{
label: "Request",
click: () => changePage(mainWindow, "/request")
},
{
label: "Cards",
click: () => changePage(mainWindow, "/card")
},
{ type: "separator" },
{
label: "Quit",
click: () => app.quit()
}
]);
tray.setContextMenu(contextMenu);
tray.setToolTip("BunqDesktop");

// Event handlers
tray.on("click", () => {
// show app on single click
if (!mainWindow.isVisible()) mainWindow.show();
});
tray.on("double-click", () => {
// hide app on double click
if (mainWindow.isVisible()) mainWindow.hide();
});
const createTrayIcon = () => {
// setup the tray handler
const tray = new Tray(trayIcon);
const contextMenu = Menu.buildFromTemplate([
{
label: "Dashboard",
click: () => changePage(mainWindow, "/")
},
{
label: "Pay",
click: () => changePage(mainWindow, "/pay")
},
{
label: "Request",
click: () => changePage(mainWindow, "/request")
},
{
label: "Cards",
click: () => changePage(mainWindow, "/card")
},
{ type: "separator" },
{
label: "Quit",
click: () => app.quit()
}
]);
tray.setContextMenu(contextMenu);
tray.setToolTip("BunqDesktop");

// Event handlers
tray.on("click", () => {
// show app on single click
if (!mainWindow.isVisible()) mainWindow.show();
tray.destroy();
});
}

mainWindow.on("show", () => {
tray.setHighlightMode("always");
});
mainWindow.on("hide", () => {
tray.setHighlightMode("never");
});
mainWindow.on("minimize", function(event) {
const minimizeToTray = !!settings.get("MINIMIZE_TO_TRAY_LOCATION");
const minimizeToTray = !!settings.get("MINIMIZE_TO_TRAY");
if (minimizeToTray) {
createTrayIcon();
event.preventDefault();
mainWindow.hide();
}
Expand Down

0 comments on commit 3a5efcd

Please sign in to comment.