1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

broadcast update available only after downloading update

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-02-25 08:54:42 -05:00
parent e837e6f1db
commit 2ae30cb285

View File

@ -39,10 +39,10 @@ export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 24
autoUpdater.autoInstallOnAppQuit = false;
autoUpdater
.on("update-available", (args: UpdateInfo) => {
.on("update-available", (info: UpdateInfo) => {
if (autoUpdater.autoInstallOnAppQuit) {
// a previous auto-update loop was completed with YES+LATER, check if same version
if (installVersion === args.version) {
if (installVersion === info.version) {
// same version, don't broadcast
return;
}
@ -54,10 +54,14 @@ export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 24
* didn't ask for.
*/
autoUpdater.autoInstallOnAppQuit = false;
installVersion = args.version;
installVersion = info.version;
autoUpdater.downloadUpdate()
.catch(error => logger.error(`${AutoUpdateLogPrefix}: failed to download update`, { error: String(error) }));
})
.on("update-downloaded", (info: UpdateInfo) => {
try {
const backchannel = `auto-update:${args.version}`;
const backchannel = `auto-update:${info.version}`;
ipcMain.removeAllListeners(backchannel); // only one handler should be present
@ -68,8 +72,8 @@ export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 24
listener: handleAutoUpdateBackChannel,
verifier: areArgsUpdateAvailableToBackchannel,
});
logger.info(`${AutoUpdateLogPrefix}: broadcasting update available`, { backchannel, version: args.version });
broadcastMessage(UpdateAvailableChannel, backchannel, args);
logger.info(`${AutoUpdateLogPrefix}: broadcasting update available`, { backchannel, version: info.version });
broadcastMessage(UpdateAvailableChannel, backchannel, info);
} catch (error) {
logger.error(`${AutoUpdateLogPrefix}: broadcasting failed`, { error });
installVersion = undefined;