mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/version: convert to readable
This commit is contained in:
parent
0e60ea9582
commit
c3c7a6b7ba
2 changed files with 17 additions and 15 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import { readable } from "svelte/store";
|
||||||
|
|
||||||
type VersionResponse = {
|
type VersionResponse = {
|
||||||
commit: string;
|
commit: string;
|
||||||
branch: string;
|
branch: string;
|
||||||
|
@ -5,19 +7,19 @@ type VersionResponse = {
|
||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchVersion = async function () {
|
const unknownVersion = {
|
||||||
const response: VersionResponse | undefined = await fetch('/version.json')
|
commit: "unknown",
|
||||||
.then(r => r.json())
|
branch: "unknown",
|
||||||
.catch(() => {});
|
remote: "unknown",
|
||||||
|
version: "unknown"
|
||||||
|
};
|
||||||
|
|
||||||
if (!response) return {
|
export const version = readable<VersionResponse>(
|
||||||
commit: "unknown",
|
unknownVersion,
|
||||||
branch: "unknown",
|
(set) => {
|
||||||
remote: "unknown",
|
fetch('/version.json')
|
||||||
version: "unknown"
|
.then(r => r.json())
|
||||||
|
.then(set)
|
||||||
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
)
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const version = await fetchVersion();
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
<h3>version:</h3>
|
<h3>version:</h3>
|
||||||
<div class="message-container subtext">
|
<div class="message-container subtext">
|
||||||
{JSON.stringify(version, null, 2)}
|
{JSON.stringify($version, null, 2)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue