Force app to quit on Mac when we auto update
This commit is contained in:
parent
07d8b862db
commit
db62494109
4 changed files with 22 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
|
6
main.js
6
main.js
|
@ -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
|
||||
|
|
|
@ -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
14
window_state.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
let shouldQuitFlag = false;
|
||||
|
||||
function markShouldQuit() {
|
||||
shouldQuitFlag = true;
|
||||
}
|
||||
|
||||
function shouldQuit() {
|
||||
return shouldQuitFlag;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
shouldQuit,
|
||||
markShouldQuit
|
||||
};
|
Loading…
Reference in a new issue