web/settings: make version info optional, wait for load

This commit is contained in:
dumbmoron 2024-07-23 09:36:49 +00:00
parent 23c9eb73aa
commit 89181c6ddc
No known key found for this signature in database
2 changed files with 4 additions and 10 deletions

View file

@ -1,4 +1,5 @@
import { readable } from "svelte/store";
import type { Optional } from "./types/generic";
type VersionResponse = {
commit: string;
@ -7,15 +8,8 @@ type VersionResponse = {
version: string;
}
const unknownVersion = {
commit: "unknown",
branch: "unknown",
remote: "unknown",
version: "unknown"
};
export const version = readable<VersionResponse>(
unknownVersion,
export const version = readable<Optional<VersionResponse>>(
undefined,
(set) => {
fetch('/version.json')
.then(r => r.json())

View file

@ -25,7 +25,7 @@
let screenWidth: number;
$: versionText = `v.${$version.version}-${$version.commit.slice(0, 7)}`;
$: versionText = $version ? `v${$version.version}-${$version.commit.slice(0, 8)}` : '\xa0';
$: currentPageTitle = $page.url.pathname.split("/").at(-1);
$: stringPageTitle =