mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-10-31 08:15:07 +00:00
feat(desktop): show what's changed in auto-update prompt
Publish HEALTHCHAT_CHANGES.md release notes into the update feeds so users see what changed. macOS gets them natively via releases.json's notes field; Windows fetches a published notes.txt, since Squirrel.Windows only delivers releaseName through the update-downloaded event.
This commit is contained in:
@@ -78,6 +78,7 @@ export async function start(updateBaseUrl: string): Promise<void> {
|
||||
if (!updateBaseUrl.endsWith("/")) {
|
||||
updateBaseUrl = updateBaseUrl + "/";
|
||||
}
|
||||
updateFeedBaseUrl = updateBaseUrl;
|
||||
|
||||
try {
|
||||
let url: string;
|
||||
@@ -184,6 +185,27 @@ interface ICachedUpdate {
|
||||
updateURL: string;
|
||||
}
|
||||
|
||||
// The feed base URL passed to start(), retained so the update-downloaded handler can fetch
|
||||
// release notes out-of-band on Windows (see below).
|
||||
let updateFeedBaseUrl: string | undefined;
|
||||
|
||||
// On Windows the autoUpdater never provides release notes: "With Squirrel.Windows only
|
||||
// releaseName is available" (https://www.electronjs.org/docs/latest/api/auto-updater). We
|
||||
// publish a notes.txt alongside the per-arch Squirrel feed and fetch it here so the renderer's
|
||||
// update toast can show "what's changed" the same way it does on macOS (where Squirrel.Mac
|
||||
// carries the notes natively via releases.json).
|
||||
async function fetchWindowsReleaseNotes(): Promise<string> {
|
||||
if (process.platform !== "win32" || !updateFeedBaseUrl) return "";
|
||||
try {
|
||||
const res = await fetch(`${updateFeedBaseUrl}win32/${process.arch}/notes.txt`);
|
||||
if (!res.ok) return "";
|
||||
return await res.text();
|
||||
} catch (err) {
|
||||
console.log("Couldn't fetch Windows release notes", err);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// cache the latest update which has been downloaded as electron offers no api to read it
|
||||
let latestUpdateDownloaded: ICachedUpdate | undefined;
|
||||
autoUpdater
|
||||
@@ -205,7 +227,13 @@ autoUpdater
|
||||
});
|
||||
|
||||
autoUpdater.on("update-downloaded", (ev, releaseNotes, releaseName, releaseDate, updateURL) => {
|
||||
// forward to renderer
|
||||
latestUpdateDownloaded = { releaseNotes, releaseName, releaseDate, updateURL };
|
||||
global.mainWindow?.webContents.send("update-downloaded", latestUpdateDownloaded);
|
||||
void (async (): Promise<void> => {
|
||||
// Windows delivers no release notes via the event, so fetch them out-of-band.
|
||||
if (!releaseNotes) {
|
||||
releaseNotes = await fetchWindowsReleaseNotes();
|
||||
}
|
||||
// forward to renderer
|
||||
latestUpdateDownloaded = { releaseNotes, releaseName, releaseDate, updateURL };
|
||||
global.mainWindow?.webContents.send("update-downloaded", latestUpdateDownloaded);
|
||||
})();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user