From 313517605b4e67af4ede5de69f37fa1319aef73b Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 24 Jun 2024 00:20:30 +0100 Subject: [PATCH] Update feature block on stats page --- src/routes/more/statistics/+page.svelte | 38 ++++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/routes/more/statistics/+page.svelte b/src/routes/more/statistics/+page.svelte index d43febe..e1a8298 100644 --- a/src/routes/more/statistics/+page.svelte +++ b/src/routes/more/statistics/+page.svelte @@ -4,9 +4,12 @@ import Loading from "$lib/navigation/loading.svelte"; import Nav from "$lib/navigation/nav.svelte"; import { getApiUrl } from "$lib/scripts/upstream"; - import { featureDetect } from "$lib/scripts/featureDetect"; + import { featureDetect, type FeatureDetectionResult } from "$lib/scripts/featureDetect"; import { getCurrentLocation } from "$lib/scripts/getLocation"; + import { onMount } from "svelte"; const title = "Statistics"; + let features: FeatureDetectionResult | null = null; + let error: Error | null = null; async function getData() { const url = `${getApiUrl()}/misc/server/stats`; @@ -14,6 +17,18 @@ return await res.json(); } + async function loadFeatures() { + try { + features = await featureDetect(); + } catch (e) { + error = e; + } + } + + onMount(() => { + loadFeatures(); + }); + function U2L(input: Date | number): string { if (input instanceof Date) { return input.toLocaleString(); @@ -67,9 +82,9 @@ {/await}

Browser Features

-{#await featureDetect()} - Checking browser features -{:then features} +{#if features === null && error === null} + Checking browser features... +{:else if features !== null}

Critical Features

{#if !features.critical}

@@ -129,20 +144,9 @@ -{:catch error} +{:else if error !== null} Failed to detect browser features: {error.message} -{/await} - -

Detected Location

-{#await getCurrentLocation()} - Fetching Location... -{:then location} - {location.latitude}, {location.longitude} -
- View on Map -{:catch error} - {error.message} -{/await} +{/if}