Skip to content

Commit

Permalink
Fix show app in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
daquinons committed Aug 27, 2019
1 parent 817ad61 commit 1badb66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
22 changes: 11 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const path = require('path');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
app.mainWindow;
const windowWidth = 375;
const windowHeight = 350;

function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
app.mainWindow = new BrowserWindow({
icon: path.join(__dirname, 'assets/icons/png/64x64.png'),
alwaysOnTop: true,
backgroundColor: '#EB5757',
Expand All @@ -35,23 +35,23 @@ function createWindow() {
});

// and load the index.html of the app.
mainWindow.loadFile('index.html');
app.mainWindow.loadFile('index.html');

// Open the DevTools.
// mainWindow.webContents.openDevTools()
// app.mainWindow.webContents.openDevTools()

// Emitted when the window is closed.
mainWindow.on('close', function(event) {
app.mainWindow.on('close', function(event) {
/* // Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null; */
app.mainWindow = null; */
if (process.platform !== 'darwin') {
app.quit();
} else {
if (!app.isQuitting) {
event.preventDefault();
mainWindow.hide();
app.mainWindow.hide();
}
}

Expand Down Expand Up @@ -231,7 +231,7 @@ function createWindow() {
{
label: 'Show App',
click: function() {
mainWindow.show();
app.mainWindow.show();
}
},
{
Expand Down Expand Up @@ -263,14 +263,14 @@ app.on('window-all-closed', function() {
});

app.on('before-quit', function() {
mainWindow.destroy();
app.mainWindow.destroy();
});

app.on('activate', function() {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) createWindow();
else mainWindow.show();
if (app.mainWindow === null) createWindow();
else app.mainWindow.show();
});

// In this file you can include the rest of your app's specific main process
Expand Down
6 changes: 1 addition & 5 deletions src/utils/updateTray.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ function setMenuCompletedPomodoros(completedTimer) {
const contextMenu = Menu.buildFromTemplate([
{
label: completedText,
click: function() {}
},
{
label: 'Show App',
click: function() {
mainWindow.show();
app.mainWindow.show();
}
},
{
Expand Down

0 comments on commit 1badb66

Please sign in to comment.