blockLoading of near to me card until stores have been read

This commit is contained in:
Fred Boniface 2024-07-12 15:26:51 +01:00
parent e3632986c2
commit 2b8d32f3c9
1 changed files with 20 additions and 14 deletions

View File

@ -15,6 +15,7 @@
let errorMessage: string; let errorMessage: string;
let stations: NearestStationResponse[] = []; let stations: NearestStationResponse[] = [];
let blockLoading: boolean = true;
let config: CardConfig = { let config: CardConfig = {
title: "Near to Me", title: "Near to Me",
@ -58,28 +59,33 @@
getNearestStations(); getNearestStations();
} }
} }
blockLoading = false;
}); });
</script> </script>
<Card {config}> <Card {config}>
{#if !$uuid || $uuid === "null"} {#if blockLoading}
<LinkButton text="Register to use this feature" link="/more/reg" /> <InLineLoading />
{:else if $location} {:else}
{#if !stations.length} {#if !$uuid || $uuid === "null"}
{#if errorMessage} <LinkButton text="Register to use this feature" link="/more/reg" />
<p>{errorMessage}</p> {:else if $location}
{#if !stations.length}
{#if errorMessage}
<p>{errorMessage}</p>
{:else}
<InLineLoading />
{/if}
{:else} {:else}
<InLineLoading /> <div id="buttons">
{#each stations as station}
<LinkButton text={`${station.NLCDESC} - ${station.miles}mi`} link={`/ldb?station=${station["3ALPHA"]}`} />
{/each}
</div>
{/if} {/if}
{:else} {:else}
<div id="buttons"> <ScriptButton text={"Turn on Location"} fn={turnOnLocation} />
{#each stations as station}
<LinkButton text={`${station.NLCDESC} - ${station.miles}mi`} link={`/ldb?station=${station["3ALPHA"]}`} />
{/each}
</div>
{/if} {/if}
{:else}
<ScriptButton text={"Turn on Location"} fn={turnOnLocation} />
{/if} {/if}
</Card> </Card>