Skip to content

Commit ae5b85d

Browse files
committed
Autoupdate modal: add download/disable updates buttons
1 parent 47b4414 commit ae5b85d

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

index.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
getEnabledPlugins,
1212
isAppVisible,
1313
isTrayEnabled,
14+
setOptions,
1415
store,
1516
startAtLogin,
1617
} = require("./store");
@@ -196,15 +197,29 @@ app.on("ready", () => {
196197
if (!is.dev() && autoUpdate()) {
197198
autoUpdater.checkForUpdatesAndNotify();
198199
autoUpdater.on("update-available", () => {
200+
const downloadLink =
201+
"https://github.com/th-ch/youtube-music/releases/latest";
199202
const dialogOpts = {
200203
type: "info",
201-
buttons: ["OK"],
204+
buttons: ["OK", "Download", "Disable updates"],
202205
title: "Application Update",
203206
message: "A new version is available",
204-
detail:
205-
"A new version is available and can be downloaded at https://github.com/th-ch/youtube-music/releases/latest",
207+
detail: `A new version is available and can be downloaded at ${downloadLink}`,
206208
};
207-
electron.dialog.showMessageBox(dialogOpts);
209+
electron.dialog.showMessageBox(dialogOpts).then((dialogOutput) => {
210+
switch (dialogOutput.response) {
211+
// Download
212+
case 1:
213+
electron.shell.openExternal(downloadLink);
214+
break;
215+
// Disable updates
216+
case 2:
217+
setOptions({ autoUpdates: false });
218+
break;
219+
default:
220+
break;
221+
}
222+
});
208223
});
209224
}
210225

0 commit comments

Comments
 (0)