From ae5b85d8d748659f2e23d417560026f24ab8ce9c Mon Sep 17 00:00:00 2001 From: TC Date: Sat, 28 Nov 2020 18:13:41 +0100 Subject: [PATCH] Autoupdate modal: add download/disable updates buttons --- index.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 1f45b7bc..d1f44974 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,7 @@ const { getEnabledPlugins, isAppVisible, isTrayEnabled, + setOptions, store, startAtLogin, } = require("./store"); @@ -196,15 +197,29 @@ app.on("ready", () => { if (!is.dev() && autoUpdate()) { autoUpdater.checkForUpdatesAndNotify(); autoUpdater.on("update-available", () => { + const downloadLink = + "https://github.com/th-ch/youtube-music/releases/latest"; const dialogOpts = { type: "info", - buttons: ["OK"], + buttons: ["OK", "Download", "Disable updates"], title: "Application Update", message: "A new version is available", - detail: - "A new version is available and can be downloaded at https://github.com/th-ch/youtube-music/releases/latest", + detail: `A new version is available and can be downloaded at ${downloadLink}`, }; - electron.dialog.showMessageBox(dialogOpts); + electron.dialog.showMessageBox(dialogOpts).then((dialogOutput) => { + switch (dialogOutput.response) { + // Download + case 1: + electron.shell.openExternal(downloadLink); + break; + // Disable updates + case 2: + setOptions({ autoUpdates: false }); + break; + default: + break; + } + }); }); }