diff --git a/web/src/lib/version.ts b/web/src/lib/version.ts index ff9b4a0b..22539f55 100644 --- a/web/src/lib/version.ts +++ b/web/src/lib/version.ts @@ -1,3 +1,5 @@ +import { readable } from "svelte/store"; + type VersionResponse = { commit: string; branch: string; @@ -5,19 +7,19 @@ type VersionResponse = { version: string; } -const fetchVersion = async function () { - const response: VersionResponse | undefined = await fetch('/version.json') - .then(r => r.json()) - .catch(() => {}); +const unknownVersion = { + commit: "unknown", + branch: "unknown", + remote: "unknown", + version: "unknown" +}; - if (!response) return { - commit: "unknown", - branch: "unknown", - remote: "unknown", - version: "unknown" +export const version = readable( + unknownVersion, + (set) => { + fetch('/version.json') + .then(r => r.json()) + .then(set) + .catch(() => {}) } - - return response; -} - -export const version = await fetchVersion(); +) diff --git a/web/src/routes/settings/advanced/debug/+page.svelte b/web/src/routes/settings/advanced/debug/+page.svelte index 9dd63bd9..05feefeb 100644 --- a/web/src/routes/settings/advanced/debug/+page.svelte +++ b/web/src/routes/settings/advanced/debug/+page.svelte @@ -32,7 +32,7 @@

version:

- {JSON.stringify(version, null, 2)} + {JSON.stringify($version, null, 2)}
{/if}