Skip to content

Commit

Permalink
Fixed bug where a new window is created when altair mac app is activated
Browse files Browse the repository at this point in the history
from dock.
Closes #264.
  • Loading branch information
imolorhe committed Mar 28, 2018
1 parent 1f73985 commit 9f61f40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions electron/main.js
@@ -1,14 +1,14 @@
const {app, protocol } = require('electron');
const { app, protocol } = require('electron');
const isDev = require('electron-is-dev');
const { setupAutoUpdates } = require('./updates');
const { instance, createWindow } = require('./window');
const { instance, createWindow, getInstance } = require('./window');

// Default Squirrel.Windows event handler for your Electron apps.
// if (require('electron-squirrel-startup')) return; // Not required when using NSIS target

// 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 win = instance;
let win = getInstance();

protocol.registerStandardSchemes(['altair']);

Expand All @@ -34,7 +34,7 @@ app.on('window-all-closed', () => {
app.on('activate', () => {
// 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 (instance === null) {
if (getInstance() === null) {
createWindow();
}
});
Expand Down
3 changes: 3 additions & 0 deletions electron/window.js
Expand Up @@ -92,7 +92,10 @@ const createWindow = () => {
})
};

const getInstance = () => instance;

module.exports = {
getInstance,
instance,
createWindow,
actions
Expand Down

0 comments on commit 9f61f40

Please sign in to comment.