Add live indicator to board page
This commit is contained in:
@@ -6,8 +6,10 @@
|
||||
|
||||
import { formatUkDateTime, formatUkTime } from '$lib/utils/time';
|
||||
import StaffServicesTable from '$lib/components/ui/station-board/StaffServicesTable.svelte';
|
||||
import LiveIndicator from '$lib/components/ui/LiveIndicator.svelte';
|
||||
let { data } = $props();
|
||||
let now = $state(new Date());
|
||||
let live = $state(false);
|
||||
|
||||
// Handle auto-refreshing & Wake-lock
|
||||
$effect(() => {
|
||||
@@ -46,8 +48,10 @@
|
||||
await invalidateAll();
|
||||
} catch (error) {
|
||||
console.error("Background data fetch failed: ", error)
|
||||
live = false;
|
||||
}
|
||||
}, 61000);
|
||||
live = true;
|
||||
console.log("Polling started")
|
||||
};
|
||||
|
||||
@@ -107,12 +111,14 @@ $effect(() => {
|
||||
// Load Data Invalidation Handling
|
||||
// Refresh countdown logic
|
||||
</script>
|
||||
|
||||
<section class="board-wrapper">
|
||||
<div class="time-data">
|
||||
<span class="time-loaded">Updated: {formatUkDateTime(data.boardData.producedAt, true)}</span>
|
||||
<span class="time-now">{formatUkTime(now, true)}</span>
|
||||
</div>
|
||||
{#if live}
|
||||
<LiveIndicator />
|
||||
{/if}
|
||||
{#if data.boardData.data.m?.length}
|
||||
<StationAlertCard messages={data.boardData.data.m} />
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user