Force app to quit on Mac when we auto update

This commit is contained in:
David Balatero 2017-06-21 17:26:05 -07:00 committed by Scott Nonnenberg
parent 07d8b862db
commit db62494109
No known key found for this signature in database
GPG Key ID: A4931C09644C654B
4 changed files with 22 additions and 2 deletions

View File

@ -1,6 +1,8 @@
const autoUpdater = require('electron-updater').autoUpdater
const { dialog } = require('electron');
const windowState = require('./window_state');
const hour = 60 * 60;
const autoUpdaterInterval = hour * 1000;
@ -32,6 +34,7 @@ function showUpdateDialog(localeMessages) {
dialog.showMessageBox(options, function(response) {
if (response == RESTART_BUTTON) {
windowState.markShouldQuit();
autoUpdater.quitAndInstall();
}
});

View File

@ -11,6 +11,7 @@ const ElectronConfig = require('electron-config');
const autoupdate = require('./autoupdate');
const locale = require('./locale');
const windowState = require('./window_state');
console.log('setting AUMID');
app.setAppUserModelId('org.whispersystems.signal-desktop')
@ -184,7 +185,7 @@ function createWindow () {
// Emitted when the window is about to be closed.
mainWindow.on('close', function (e) {
if (process.platform === 'darwin' && !shouldQuit && environment !== 'test') {
if (process.platform === 'darwin' && !windowState.shouldQuit() && environment !== 'test') {
e.preventDefault();
mainWindow.hide();
}
@ -224,8 +225,9 @@ app.on('ready', function() {
})
app.on('before-quit', function() {
shouldQuit = true;
windowState.markShouldQuit();
});
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar

View File

@ -110,6 +110,7 @@
"!js/register.js",
"!js/views/standalone_registration_view.js",
"preload.js",
"window_state.js",
"autoupdate.js",
"locale.js",
"main.js",

14
window_state.js Normal file
View File

@ -0,0 +1,14 @@
let shouldQuitFlag = false;
function markShouldQuit() {
shouldQuitFlag = true;
}
function shouldQuit() {
return shouldQuitFlag;
}
module.exports = {
shouldQuit,
markShouldQuit
};