Skip to content

Commit

Permalink
fix: app quitting when accepting update (#1118)
Browse files Browse the repository at this point in the history
The app wouldn't completely quit after an update was downloaded and the user has pressed "USE IT NOW".
  • Loading branch information
IGassmann authored Mar 17, 2018
1 parent 861131f commit 8839995
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/createWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default appState => {
setupContextMenu(window);

window.on('close', event => {
if (!appState.isQuitting) {
if (!appState.isQuitting && !appState.autoUpdateAccepted) {
event.preventDefault();
window.hide();
}
Expand Down
7 changes: 2 additions & 5 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ autoUpdater.autoDownload = true;
// it will still install on shutdown.
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
// that we show on Windows after you decline an upgrade and close the app later.
let showingAutoUpdateCloseAlert = false;
Expand Down Expand Up @@ -88,7 +85,7 @@ app.on('will-quit', event => {
if (
process.platform === 'win32' &&
autoUpdateDownloaded &&
!autoUpdateAccepted &&
!appState.autoUpdateAccepted &&
!showingAutoUpdateCloseAlert
) {
// We're on Win and have an update downloaded, but the user declined it (or closed
Expand Down Expand Up @@ -152,7 +149,7 @@ autoUpdater.on('update-downloaded', () => {
});

ipcMain.on('autoUpdateAccepted', () => {
autoUpdateAccepted = true;
appState.autoUpdateAccepted = true;
autoUpdater.quitAndInstall();
});

Expand Down

0 comments on commit 8839995

Please sign in to comment.