Skip to content

Commit

Permalink
fix(App): Force Franz to use single window
Browse files Browse the repository at this point in the history
Fixes #29
  • Loading branch information
adlk committed Oct 23, 2017
1 parent 8e3dcd4 commit 2ae409e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import './electron/exception';
// 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;
const settings = new Settings();
let willQuitApp = false;

// Ensure that the recipe directory exists
Expand All @@ -29,6 +28,21 @@ if (isWindows) {
app.setAppUserModelId(appId);
}

// Force single window
const isSecondInstance = app.makeSingleInstance(() => {
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
});

if (isSecondInstance) {
app.quit();
}

// Initialize Settings
const settings = new Settings();

const createWindow = async () => {
// Remember window size
const mainWindowState = windowStateKeeper({
Expand Down

0 comments on commit 2ae409e

Please sign in to comment.