From 000d088db427fb844eb67121b2223202067c1c80 Mon Sep 17 00:00:00 2001 From: Sandwich <299465+dskvr@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:42:34 +0700 Subject: [PATCH] improve load speed --- .../lib/components/partials/RelayMap.svelte | 17 ++++--- .../relay-single/cards/CardMap.svelte | 13 +++-- .../relay-single/cards/CardOperator.svelte | 10 +--- .../relays/[protocol]/[...relay]/+page.svelte | 47 ++++++++++++++----- libraries/nip66/src/services/RelayService.ts | 11 +++-- libraries/nip66/src/services/Service.ts | 3 ++ 6 files changed, 65 insertions(+), 36 deletions(-) diff --git a/apps/gui/src/lib/components/partials/RelayMap.svelte b/apps/gui/src/lib/components/partials/RelayMap.svelte index a81ad232..4c46b4a2 100644 --- a/apps/gui/src/lib/components/partials/RelayMap.svelte +++ b/apps/gui/src/lib/components/partials/RelayMap.svelte @@ -10,8 +10,8 @@ import { StateManager } from '@nostrwatch/nip66'; export let relay: string; - export let monitors: Monitor[]; - export let checks: Nip66Event[]; + export let monitors: Writable + export let checks: Writable export let aggregate: any; let ready: boolean = false; @@ -81,8 +81,10 @@ } const setMonitor = (monitor: Monitor) => { + if(!monitor?.registration) return; const { dd } = monitor.registration - const monitorCheck: Nip66Event = checks.find( check => check.pubkey === monitor.pubkey ) + const monitorCheck: Nip66Event | undefined = $checks.find( check => check.pubkey === monitor.pubkey ) + if(!monitorCheck) return //console.warn(`${monitor.pubkey} could not find check data...`) const rtt = monitorCheck?.rtt || undefined //console.log('monitor data', monitor, monitor.pubkey, dd, monitorCheck, rtt) @@ -114,7 +116,7 @@ const setMonitors = async (): Promise => { resetMonitors() - for ( const monitor of monitors) { + for ( const monitor of $monitors) { setMonitor(monitor) } } @@ -204,9 +206,10 @@ }; - onMount( () => { - init() - }) + onMount(init) + + monitors.subscribe(init) + checks.subscribe(init) {#if ready === true} diff --git a/apps/gui/src/lib/components/partials/relay-single/cards/CardMap.svelte b/apps/gui/src/lib/components/partials/relay-single/cards/CardMap.svelte index aeafc2d1..590b6b36 100644 --- a/apps/gui/src/lib/components/partials/relay-single/cards/CardMap.svelte +++ b/apps/gui/src/lib/components/partials/relay-single/cards/CardMap.svelte @@ -1,22 +1,27 @@ -{#if monitors.length && checks.length} + Checks Map A map showing where monitors reported from + {#if $monitors.length && $checks.length} + {:else} + loading.... + {/if} -{/if} \ No newline at end of file diff --git a/apps/gui/src/lib/components/partials/relay-single/cards/CardOperator.svelte b/apps/gui/src/lib/components/partials/relay-single/cards/CardOperator.svelte index c549691f..862406d0 100644 --- a/apps/gui/src/lib/components/partials/relay-single/cards/CardOperator.svelte +++ b/apps/gui/src/lib/components/partials/relay-single/cards/CardOperator.svelte @@ -1,20 +1,15 @@