fix: app quitting when accepting update (#1118)

The app wouldn't completely quit after an update was downloaded and the user has pressed "USE IT NOW".
This commit is contained in:
Igor Gassmann 2018-03-17 16:44:46 -04:00 committed by GitHub
parent 861131fd77
commit 88399957ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View file

@ -49,7 +49,7 @@ export default appState => {
setupContextMenu(window); setupContextMenu(window);
window.on('close', event => { window.on('close', event => {
if (!appState.isQuitting) { if (!appState.isQuitting && !appState.autoUpdateAccepted) {
event.preventDefault(); event.preventDefault();
window.hide(); window.hide();
} }

View file

@ -19,9 +19,6 @@ autoUpdater.autoDownload = true;
// it will still install on shutdown. // it will still install on shutdown.
let autoUpdateDownloaded = false; let autoUpdateDownloaded = false;
// Keeps track of whether the user has accepted an auto-update through the interface.
let autoUpdateAccepted = false;
// This is used to keep track of whether we are showing the special dialog // This is used to keep track of whether we are showing the special dialog
// that we show on Windows after you decline an upgrade and close the app later. // that we show on Windows after you decline an upgrade and close the app later.
let showingAutoUpdateCloseAlert = false; let showingAutoUpdateCloseAlert = false;
@ -88,7 +85,7 @@ app.on('will-quit', event => {
if ( if (
process.platform === 'win32' && process.platform === 'win32' &&
autoUpdateDownloaded && autoUpdateDownloaded &&
!autoUpdateAccepted && !appState.autoUpdateAccepted &&
!showingAutoUpdateCloseAlert !showingAutoUpdateCloseAlert
) { ) {
// We're on Win and have an update downloaded, but the user declined it (or closed // We're on Win and have an update downloaded, but the user declined it (or closed
@ -152,7 +149,7 @@ autoUpdater.on('update-downloaded', () => {
}); });
ipcMain.on('autoUpdateAccepted', () => { ipcMain.on('autoUpdateAccepted', () => {
autoUpdateAccepted = true; appState.autoUpdateAccepted = true;
autoUpdater.quitAndInstall(); autoUpdater.quitAndInstall();
}); });