fix: daemon doesn't quit when quitting the app for an auto-update (https://github.com/lbryio/lbry-app/issues/1142)

Fix https://github.com/lbryio/lbry-app/issues/1142
This commit is contained in:
Igor Gassmann 2018-03-19 15:57:42 -04:00
parent 88399957ef
commit 034398859e

View file

@ -14,15 +14,6 @@ import createWindow from './createWindow';
autoUpdater.autoDownload = true;
// This is set to true if an auto update has been downloaded through the Electron
// auto-update system and is ready to install. If the user declined an update earlier,
// it will still install on shutdown.
let autoUpdateDownloaded = 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;
// Keep a global reference, if you don't, they will be closed automatically when the JavaScript
// object is garbage collected.
let rendererWindow;
@ -84,16 +75,16 @@ app.on('activate', () => {
app.on('will-quit', event => {
if (
process.platform === 'win32' &&
autoUpdateDownloaded &&
appState.autoUpdateDownloaded &&
!appState.autoUpdateAccepted &&
!showingAutoUpdateCloseAlert
!appState.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 postponed it (or closed
// the app without accepting it). Now the user is closing the app, so the new update
// will install. On Mac this is silent, but on Windows they get a confusing permission
// escalation dialog, so we show Windows users a warning dialog first.
showingAutoUpdateCloseAlert = true;
appState.showingAutoUpdateCloseAlert = true;
dialog.showMessageBox(
{
type: 'info',
@ -126,6 +117,9 @@ app.on('will-finish-launching', () => {
app.on('before-quit', () => {
appState.isQuitting = true;
if (appState.autoUpdateAccepted) {
if (daemon) daemon.quit();
}
});
ipcMain.on('upgrade', (event, installerPath) => {
@ -145,7 +139,7 @@ ipcMain.on('upgrade', (event, installerPath) => {
});
autoUpdater.on('update-downloaded', () => {
autoUpdateDownloaded = true;
appState.autoUpdateDownloaded = true;
});
ipcMain.on('autoUpdateAccepted', () => {