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 autoUpdater = require('electron-updater').autoUpdater
|
||||||
const { dialog } = require('electron');
|
const { dialog } = require('electron');
|
||||||
|
|
||||||
|
const windowState = require('./window_state');
|
||||||
|
|
||||||
const hour = 60 * 60;
|
const hour = 60 * 60;
|
||||||
const autoUpdaterInterval = hour * 1000;
|
const autoUpdaterInterval = hour * 1000;
|
||||||
|
|
||||||
|
@ -32,6 +34,7 @@ function showUpdateDialog(localeMessages) {
|
||||||
|
|
||||||
dialog.showMessageBox(options, function(response) {
|
dialog.showMessageBox(options, function(response) {
|
||||||
if (response == RESTART_BUTTON) {
|
if (response == RESTART_BUTTON) {
|
||||||
|
windowState.markShouldQuit();
|
||||||
autoUpdater.quitAndInstall();
|
autoUpdater.quitAndInstall();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
6
main.js
6
main.js
|
@ -11,6 +11,7 @@ const ElectronConfig = require('electron-config');
|
||||||
|
|
||||||
const autoupdate = require('./autoupdate');
|
const autoupdate = require('./autoupdate');
|
||||||
const locale = require('./locale');
|
const locale = require('./locale');
|
||||||
|
const windowState = require('./window_state');
|
||||||
|
|
||||||
console.log('setting AUMID');
|
console.log('setting AUMID');
|
||||||
app.setAppUserModelId('org.whispersystems.signal-desktop')
|
app.setAppUserModelId('org.whispersystems.signal-desktop')
|
||||||
|
@ -184,7 +185,7 @@ function createWindow () {
|
||||||
|
|
||||||
// Emitted when the window is about to be closed.
|
// Emitted when the window is about to be closed.
|
||||||
mainWindow.on('close', function (e) {
|
mainWindow.on('close', function (e) {
|
||||||
if (process.platform === 'darwin' && !shouldQuit && environment !== 'test') {
|
if (process.platform === 'darwin' && !windowState.shouldQuit() && environment !== 'test') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
mainWindow.hide();
|
mainWindow.hide();
|
||||||
}
|
}
|
||||||
|
@ -224,8 +225,9 @@ app.on('ready', function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('before-quit', function() {
|
app.on('before-quit', function() {
|
||||||
shouldQuit = true;
|
windowState.markShouldQuit();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On OS X it is common for applications and their menu bar
|
// On OS X it is common for applications and their menu bar
|
||||||
|
|
|
@ -110,6 +110,7 @@
|
||||||
"!js/register.js",
|
"!js/register.js",
|
||||||
"!js/views/standalone_registration_view.js",
|
"!js/views/standalone_registration_view.js",
|
||||||
"preload.js",
|
"preload.js",
|
||||||
|
"window_state.js",
|
||||||
"autoupdate.js",
|
"autoupdate.js",
|
||||||
"locale.js",
|
"locale.js",
|
||||||
"main.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