mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-19 00:10:00 +00:00
After an update the restarted app opens what the new version brought as an editor tab, and Help > What's New reopens it at any time. Its checkbox turns the automatic opening off for later updates; the same switch sits on System Settings > Updates next to the update checks. The update balloon keeps a one-paragraph summary. The release workflow fills the updater manifest's notes from the release body without its Download section, the install records them, and a version installed outside the app reads them from the manifest. The first start of a different version is recognised from the last run version kept in settings.
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
/**
|
|
* The release notes the updater installed, kept so the What's New page can show
|
|
* them after the restart that installs an update. localStorage, because an
|
|
* update replaces the app bundle but not the webview's data.
|
|
*/
|
|
|
|
const KEY = "openidea.whatsNew.notes.v1";
|
|
|
|
interface Stored {
|
|
version: string;
|
|
text: string;
|
|
}
|
|
|
|
function read(): Stored | null {
|
|
try {
|
|
const raw = globalThis.localStorage?.getItem(KEY);
|
|
const value: unknown = raw ? JSON.parse(raw) : null;
|
|
if (!value || typeof value !== "object") return null;
|
|
const stored = value as Partial<Stored>;
|
|
return typeof stored.version === "string" && typeof stored.text === "string"
|
|
? { version: stored.version, text: stored.text }
|
|
: null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/** Called once an update installed, with the notes its manifest carried. */
|
|
export function recordInstalledUpdate(version: string, notes: string | null): void {
|
|
const text = notes?.trim();
|
|
try {
|
|
if (text) globalThis.localStorage?.setItem(KEY, JSON.stringify({ version, text }));
|
|
else globalThis.localStorage?.removeItem(KEY);
|
|
} catch {
|
|
/* storage unavailable: the page reads the manifest instead */
|
|
}
|
|
}
|
|
|
|
/** Notes recorded when this version was installed, so the page shows them offline. */
|
|
export function releaseNotesOf(version: string): string | null {
|
|
const stored = read();
|
|
return stored?.version === version ? stored.text : null;
|
|
}
|
|
|
|
/** Tests only. */
|
|
export function _resetReleaseNotesForTests(): void {
|
|
try {
|
|
globalThis.localStorage?.removeItem(KEY);
|
|
} catch {
|
|
/* storage unavailable */
|
|
}
|
|
}
|