diff --git a/main.js b/main.js index 6108de7b4..76d6da7bc 100644 --- a/main.js +++ b/main.js @@ -1,9 +1,6 @@ const electron = require('electron') -// Module to control application life. const app = electron.app -// Module to create native browser window. const BrowserWindow = electron.BrowserWindow - const path = require('path') const url = require('url') const autoUpdater = require('electron-updater').autoUpdater @@ -11,6 +8,20 @@ const autoUpdaterInterval = 60 * 60 * 1000; app.setAppUserModelId('org.whispersystems.signal-desktop') +var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) { + // Someone tried to run a second instance, we should focus our window + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore(); + mainWindow.focus(); + } + return true; +}); + +if (shouldQuit) { + app.quit(); + return; +} + // 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