Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
removed deprecated tray API on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdcruz committed Dec 3, 2019
1 parent e72d479 commit a04c41b
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions app/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const { app, BrowserWindow, Tray, Menu } = require("electron");
const {
app,
BrowserWindow,
Tray,
Menu
} = require("electron");
const gotTheLock = app.requestSingleInstanceLock();

// Keep a global reference of the window object, if you don't, the window will
Expand Down Expand Up @@ -60,26 +65,25 @@ app.once("ready", () => {
tray = new Tray("icon.ico");

// Context Menu
const contextMenu = Menu.buildFromTemplate([
{
const contextMenu = Menu.buildFromTemplate([{
label: "Show/Hide Desktop Messenger",
accelerator: "CmdOrCtrl+Q",
click: function() {
click: function () {
win.isVisible() ? win.hide() : win.show();
}
},
{
label: "Reload",
accelerator: "CmdOrCtrl+R",
click: function() {
click: function () {
win.reload();
}
},
{
label: "Clear Data/Logout",
accelerator: "CmdOrCtrl+D",
click: function() {
win.webContents.session.clearStorageData(function() {
click: function () {
win.webContents.session.clearStorageData(function () {
console.log("Data Cleaned");
});

Expand All @@ -92,7 +96,7 @@ app.once("ready", () => {
{
label: "Quit",
accelerator: "CmdOrCtrl+X",
click: function() {
click: function () {
app.quit();
}
}
Expand All @@ -102,18 +106,10 @@ app.once("ready", () => {
win.isVisible() ? win.hide() : win.show();
});

tray.on("right-click", function() {
tray.on("right-click", function () {
contextMenu();
});

win.on("show", () => {
tray.setHighlightMode("always");
});

win.on("hide", () => {
tray.setHighlightMode("never");
});

tray.setToolTip("Desktop Messenger");
tray.setContextMenu(contextMenu);
});
Expand All @@ -134,4 +130,4 @@ app.on("activate", () => {
createWindow();
win.focus();
}
});
});

0 comments on commit a04c41b

Please sign in to comment.