Make app restart after user approves update
Forgot to call quitAndInstall(). If you don't, it will still install the update, but won't restart.
This commit is contained in:
parent
b03623eb68
commit
3959d4aeee
2 changed files with 36 additions and 23 deletions
|
@ -48,10 +48,14 @@ let daemonSubprocess;
|
||||||
// if it dies when we didn't ask it to shut down, we want to alert the user.
|
// if it dies when we didn't ask it to shut down, we want to alert the user.
|
||||||
let daemonStopRequested = false;
|
let daemonStopRequested = false;
|
||||||
|
|
||||||
// This keeps track of whether the user has declined an update that was downloaded
|
|
||||||
// through the Electron auto-update system. When the user declines an update on Windows,
|
// This is set to true if an auto update has been downloaded through the Electron
|
||||||
// they will get a confusing dialog, so we show our own dialog first.
|
// auto-update system and is ready to install. If the user declined an update earlier,
|
||||||
let autoUpdateDeclined = false;
|
// 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 he special dialog
|
// This is used to keep track of whether we are showing he 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.
|
||||||
|
@ -446,20 +450,26 @@ app.on('before-quit', event => {
|
||||||
// event will be triggered re-entrantly once preparation is done.
|
// event will be triggered re-entrantly once preparation is done.
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
shutdownDaemonAndQuit();
|
shutdownDaemonAndQuit();
|
||||||
} else if (process.platform == 'win32' && autoUpdateDeclined && !showingAutoUpdateCloseAlert) {
|
} else if (autoUpdateDownloaded) {
|
||||||
// On Windows, if the user declined an update and closes the app later,
|
if (autoUpdateAccepted) {
|
||||||
// they get a confusing permission escalation dialog, so we display a
|
// User accepted the update, so install the update and restart.
|
||||||
// dialog to warn them.
|
autoUpdater.quitAndInstall();
|
||||||
event.preventDefault();
|
} else if (process.platform == 'win32' && !showingAutoUpdateCloseAlert) {
|
||||||
showingAutoUpdateCloseAlert = true;
|
// We have an update downloaded, but the user declined it (or closed the app without
|
||||||
dialog.showMessageBox({
|
// accepting it). Now the user is closing the app, so the new update will install.
|
||||||
type: "info",
|
// On Mac this is silent, but on Windows they get a confusing permission escalation
|
||||||
title: "LBRY Will Upgrade",
|
// dialog, so we show Windows users a warning dialog first.
|
||||||
message: "Please select \"Yes\" at the upgrade prompt shown after the app closes.",
|
event.preventDefault();
|
||||||
}, () => {
|
showingAutoUpdateCloseAlert = true;
|
||||||
// After the user approves the dialog, we can quit once and for all.
|
dialog.showMessageBox({
|
||||||
quitNow();
|
type: "info",
|
||||||
});
|
title: "LBRY Will Upgrade",
|
||||||
|
message: "Please select \"Yes\" at the upgrade prompt shown after the app closes.",
|
||||||
|
}, () => {
|
||||||
|
// After the user approves the dialog, we can quit once and for all.
|
||||||
|
quitNow();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -546,14 +556,17 @@ ipcMain.on('version-info-requested', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('autoUpdate', () => {
|
|
||||||
|
autoUpdater.on('update-downloaded', () => {
|
||||||
|
autoUpdateDownloaded = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('autoUpdateAccepted', () => {
|
||||||
|
autoUpdateAccepted = true;
|
||||||
minimize = false;
|
minimize = false;
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('autoUpdateDeclined', () => {
|
|
||||||
autoUpdateDeclined = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.on('get-auth-token', event => {
|
ipcMain.on('get-auth-token', event => {
|
||||||
Keytar.getPassword('LBRY', 'auth_token').then(token => {
|
Keytar.getPassword('LBRY', 'auth_token').then(token => {
|
||||||
|
|
|
@ -17,7 +17,7 @@ class ModalAutoUpdateDownloaded extends React.PureComponent {
|
||||||
confirmButtonLabel={__("Update and Restart")}
|
confirmButtonLabel={__("Update and Restart")}
|
||||||
abortButtonLabel={__("Don't Update")}
|
abortButtonLabel={__("Don't Update")}
|
||||||
onConfirmed={() => {
|
onConfirmed={() => {
|
||||||
ipcRenderer.send("autoUpdate");
|
ipcRenderer.send("autoUpdateAccepted");
|
||||||
}}
|
}}
|
||||||
onAborted={() => {
|
onAborted={() => {
|
||||||
ipcRenderer.send("autoUpdateDeclined");
|
ipcRenderer.send("autoUpdateDeclined");
|
||||||
|
|
Loading…
Add table
Reference in a new issue