diff --git a/src/features/settings/sections/DevtoolsSettings.svelte b/src/features/settings/sections/DevtoolsSettings.svelte index 6e6fb36..939678b 100644 --- a/src/features/settings/sections/DevtoolsSettings.svelte +++ b/src/features/settings/sections/DevtoolsSettings.svelte @@ -2,6 +2,7 @@ import ThreeDCard from "@shared/manga/ThreeDCard.svelte"; import { store, addToast } from "@store/state.svelte"; import { cache } from "@core/cache/index"; + import { getUiAuthDebugStatus, refreshUiAccessToken, type UiAuthDebugStatus } from "@core/auth"; import { invoke } from "@tauri-apps/api/core"; interface PerfSnapshot { cacheEntries: number; cacheKeys: string[]; oldestEntryMs: number | null; newestEntryMs: number | null; } @@ -12,13 +13,57 @@ let appVersion = $state("…"); let helloAvailable = $state(null); let helloBusy = $state(false); + let authStatus = $state(null); + let authRefreshBusy = $state(false); $effect(() => { import("@tauri-apps/api/app").then(m => m.getVersion()).then(v => appVersion = v).catch(() => {}); refreshPerfMetrics(); + refreshAuthStatus(); invoke("windows_hello_available").then(v => helloAvailable = v).catch(() => helloAvailable = false); + + const timer = setInterval(() => refreshAuthStatus(), 1000); + return () => clearInterval(timer); }); + function refreshAuthStatus() { + authStatus = getUiAuthDebugStatus(); + } + + function fmtCountdown(ms: number | null): string { + if (ms === null) return "—"; + if (ms <= 0) return "expired"; + const total = Math.floor(ms / 1000); + const hours = Math.floor(total / 3600); + const mins = Math.floor((total % 3600) / 60); + const secs = total % 60; + if (hours > 0) return `${hours}h ${mins}m ${secs}s`; + if (mins > 0) return `${mins}m ${secs}s`; + return `${secs}s`; + } + + function fmtTime(ts: number | null): string { + if (ts === null) return "—"; + return new Date(ts).toLocaleTimeString(); + } + + async function forceTokenRefresh() { + authRefreshBusy = true; + try { + const token = await refreshUiAccessToken(true); + addToast({ + kind: token ? "success" : "info", + title: "UI auth refresh", + body: token ? "Refresh succeeded" : "No refreshed token available", + }); + } catch (e: any) { + addToast({ kind: "error", title: "UI auth refresh", body: String(e?.message ?? e) }); + } finally { + authRefreshBusy = false; + refreshAuthStatus(); + } + } + function refreshPerfMetrics() { let entries = 0, oldest: number | null = null, newest: number | null = null; const foundKeys: string[] = []; @@ -75,7 +120,7 @@
Fire test toastTriggers each kind with realistic content
- {#each ([["success","S"],["error","E"],["info","I"],["download","D"]] as const) as [kind, label]} + {#each ([["success","S"],["error","E"],["info","I"],["download","D"]] as const) as [kind, label] (kind)} + +
+
+ + + \ No newline at end of file