Skip to content

Commit

Permalink
Work around a electron-updater issue
Browse files Browse the repository at this point in the history
It looks like UpdateInfo is not actually available for update-available
  • Loading branch information
Stanzilla committed May 11, 2024
1 parent cd148c6 commit 9c37435
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions src/components/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import type {
UpdateInfo,
} from "electron-updater";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type UpdaterEventArg =
| { status: "error"; error: Error; message?: string }
| { status: "download-progress"; progressInfo: ProgressInfo }
Expand Down Expand Up @@ -334,51 +335,52 @@ export default defineComponent({
}
});
ipcRenderer.on(
"updaterHandler",
(_event, status: string, arg: UpdaterEventArg) => {
console.log(`updaterHandler: ${status}`);
ipcRenderer.on("updaterHandler", (_event, status: string, arg) => {
console.log(`updaterHandler: ${status}`);
if (status === "checking-for-update") {
// No additional data for this status
return;
}
if (status === "checking-for-update") {
// No additional data for this status
return;
}
this.updater.status = status;
this.updater.status = status;
if (status === "download-progress" && "progressInfo" in arg) {
this.updater.progress = Math.floor(arg.progressInfo.percent);
}
if (status === "download-progress" && "progressInfo" in arg) {
this.updater.progress = Math.floor(arg.progressInfo.percent);
}
if (
(status === "update-available" ||
status === "update-not-available" ||
status === "update-downloaded") &&
"updateInfo" in arg
) {
this.updater.path = `https://github.com/WeakAuras/WeakAuras-Companion/releases/download/v${arg.updateInfo.version}/${arg.updateInfo.path}`;
this.updater.version = arg.updateInfo.version;
// List if `updater.fullChangelog` is set to `true`, `string` otherwise.
if (typeof arg.updateInfo.releaseNotes === "string") {
this.updater.releaseNotes = arg.updateInfo.releaseNotes;
} else if (Array.isArray(arg.updateInfo.releaseNotes)) {
// Convert the array of ReleaseNoteInfo to a string
this.updater.releaseNotes = arg.updateInfo.releaseNotes
.map((note) => note.note)
.join("\n");
} else {
this.updater.releaseNotes = "";
}
console.log(JSON.stringify(arg));
}
if (status === "update-available") {
this.updater.path = `https://github.com/WeakAuras/WeakAuras-Companion/releases/download/v${arg.version}/${arg.path}`;
this.updater.version = arg.version;
this.updater.releaseNotes = arg.releaseNotes || "";
}
if (status === "error" && "error" in arg) {
console.error(arg.error);
if (
(status === "update-not-available" || status === "update-downloaded") &&
"updateInfo" in arg
) {
this.updater.path = `https://github.com/WeakAuras/WeakAuras-Companion/releases/download/v${arg.updateInfo.version}/${arg.updateInfo.path}`;
this.updater.version = arg.updateInfo.version;
// List if `updater.fullChangelog` is set to `true`, `string` otherwise.
if (typeof arg.updateInfo.releaseNotes === "string") {
this.updater.releaseNotes = arg.updateInfo.releaseNotes;
} else if (Array.isArray(arg.updateInfo.releaseNotes)) {
// Convert the array of ReleaseNoteInfo to a string
this.updater.releaseNotes = arg.updateInfo.releaseNotes
.map((note) => note.note)
.join("\n");
} else {
this.updater.releaseNotes = "";
}
},
);
console.log(JSON.stringify(arg));
}
if (status === "error" && "error" in arg) {
console.error(arg.error);
}
});
// set default wow path
if (!this.config.wowpath.validated) {
Expand Down

0 comments on commit 9c37435

Please sign in to comment.