From e318c59098d5e975a6e65ade3d8d9bee26e4590b Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Tue, 19 Jan 2021 16:06:40 +0200 Subject: [PATCH] Show single update notification (#1985) Signed-off-by: Jari Kolehmainen --- src/main/app-updater.ts | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/src/main/app-updater.ts b/src/main/app-updater.ts index 8cbccbca64..95b8efef06 100644 --- a/src/main/app-updater.ts +++ b/src/main/app-updater.ts @@ -18,9 +18,9 @@ class NotificationBackchannel { const title = "Lens Updater"; -async function autoUpdateCheck(windowManager: WindowManager): Promise { +async function autoUpdateCheck(windowManager: WindowManager, args: UpdateInfo): Promise { return new Promise(async resolve => { - const body = "Install and restart Lens?"; + const body = `Version ${args.version} of Lens IDE is now available. Would you like to update?`; const yesNowChannel = NotificationBackchannel.nextId(); const yesLaterChannel = NotificationBackchannel.nextId(); const noChannel = NotificationBackchannel.nextId(); @@ -98,31 +98,7 @@ export function startUpdateChecking(windowManager: WindowManager, interval = 100 autoUpdater .on("update-available", async (args: UpdateInfo) => { try { - const releaseDate = moment(args.releaseDate); - const body = `Version ${args.version} of Lens IDE is now available. Would you like to update?`; - windowManager.mainView.webContents.send(NotificationChannelAdd, { - title, - body, - status: "info", - timeout: 5000, - }); - - await autoUpdateCheck(windowManager); - } catch (error) { - logger.error("[UPDATE CHECKER]: notification failed", { error: String(error) }) - } - }) - .on("update-not-available", (args: UpdateInfo) => { - try { - const version = new SemVer(args.version); - const stream = version.prerelease === null ? "stable" : "prerelease"; - const body = `Lens is running the latest ${stream} version.`; - windowManager.mainView.webContents.send(NotificationChannelAdd, { - title, - body, - status: "info", - timeout: 5000, - }) + await autoUpdateCheck(windowManager, args); } catch (error) { logger.error("[UPDATE CHECKER]: notification failed", { error: String(error) }) }