web: use turnstile & session only when the processing instance has them

now also always fetching server info in the save tab
This commit is contained in:
wukko
2024-09-18 00:24:54 +06:00
parent 0cc18b488c
commit fdd5feac92
6 changed files with 24 additions and 13 deletions

View File

@@ -7,6 +7,7 @@
import { updated } from "$app/stores";
import { browser } from "$app/environment";
import { afterNavigate } from "$app/navigation";
import { getServerInfo, cachedInfo } from "$lib/api/server-info";
import "$lib/polyfills";
import env from "$lib/env";
@@ -31,10 +32,16 @@
$settings.appearance.reduceTransparency ||
device.prefers.reducedTransparency;
afterNavigate(() => {
$: spawnTurnstile = !!$cachedInfo?.info?.cobalt?.turnstileSitekey;
afterNavigate(async() => {
const to_focus: HTMLElement | null =
document.querySelector("[data-first-focus]");
to_focus?.focus();
if ($page.url.pathname === "/") {
await getServerInfo();
}
});
</script>
@@ -77,7 +84,7 @@
<DialogHolder />
<Sidebar />
<div id="content">
{#if (env.TURNSTILE_KEY && $page.url.pathname === "/") || $turnstileCreated}
{#if (spawnTurnstile && $page.url.pathname === "/") || $turnstileCreated}
<Turnstile />
{/if}
<slot></slot>