From 046b772449d153652431de5c696f0abb17b5671c Mon Sep 17 00:00:00 2001 From: not-nullptr <62841684+not-nullptr@users.noreply.github.com> Date: Sun, 9 Feb 2025 02:31:34 +0000 Subject: [PATCH] feat: vertd connection testing --- src/lib/sections/settings/Vertd.svelte | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/lib/sections/settings/Vertd.svelte b/src/lib/sections/settings/Vertd.svelte index 65e1514..07f9562 100644 --- a/src/lib/sections/settings/Vertd.svelte +++ b/src/lib/sections/settings/Vertd.svelte @@ -5,8 +5,31 @@ import { GITHUB_URL_VERTD } from "$lib/consts"; import { RefreshCwIcon, SaveAllIcon, ServerIcon } from "lucide-svelte"; import type { Settings } from "./index.svelte"; + import clsx from "clsx"; + let vertdCommit = $state(null); const { settings }: { settings: Settings } = $props(); + + $effect(() => { + if (settings.settings.vertdURL) { + vertdCommit = "loading"; + fetch(`${settings.settings.vertdURL}/api/version`) + .then((res) => { + if (res.ok) { + res.json().then((data) => { + vertdCommit = data.data; + }); + } else { + vertdCommit = null; + } + }) + .catch(() => { + vertdCommit = null; + }); + } else { + vertdCommit = null; + } + }); @@ -19,6 +42,19 @@ /> vertd +

+ status: {vertdCommit + ? vertdCommit === "loading" + ? "loading..." + : `available, commit id ${vertdCommit}` + : "unavailable (is the url right?)"} +