diff --git a/src/routes/[year]/+layout.svelte b/src/routes/[year]/+layout.svelte index 2156774..cdd9a7d 100644 --- a/src/routes/[year]/+layout.svelte +++ b/src/routes/[year]/+layout.svelte @@ -43,27 +43,12 @@ .collection('event') .subscribe($event.id, async (data) => ($event = data.record as any)); } - if ($account && $account.role === Role.TEAM && $account.allowGps) { + if ($account && $account.role === Role.ADMIN) { + await loadPositionsAndRegisterRealtime(client); + } else if ($account && $account.allowGps) { navigator?.geolocation?.getCurrentPosition(async (pos) => { if (pos) { - const loadedPositions = await fetch(`/api/positions?year=${$page.params.year}`).then( - (res) => res.json() - ); - for (let position of loadedPositions) { - if (!$positions[position.team]) { - $positions[position.team] = position; - } - } - client.collection('position').subscribe( - '*', - async (event) => { - const position = event.record; - if (event.action === 'create') { - $positions[position.team] = position; - } - }, - { expand: 'team' } - ); + await loadPositionsAndRegisterRealtime(client); } }); } @@ -90,6 +75,26 @@ }); } } + async function loadPositionsAndRegisterRealtime(client: any) { + const loadedPositions = await fetch(`/api/positions?year=${$page.params.year}`).then((res) => + res.json() + ); + for (let position of loadedPositions) { + if (!$positions[position.team]) { + $positions[position.team] = position; + } + } + client.collection('position').subscribe( + '*', + async (event: any) => { + const position = event.record; + if (event.action === 'create') { + $positions[position.team] = position; + } + }, + { expand: 'team' } + ); + }
diff --git a/src/routes/[year]/gps/+page.svelte b/src/routes/[year]/gps/+page.svelte index d5b651b..1073f5f 100644 --- a/src/routes/[year]/gps/+page.svelte +++ b/src/routes/[year]/gps/+page.svelte @@ -1,7 +1,7 @@

GPS

-{#if hasStarted} +{#if hasStarted && $account?.role === Role.TEAM}
-{:else} +{:else if $account?.role === Role.TEAM}

Ladda om sidan då Vasagatan har börjat

{/if}
-{#if allowGps} +{#if allowGps || $account?.role === Role.ADMIN}

Positioner

Tryck på lag för att centrera karta