diff --git a/src/lib/cards/NearToMeCard.svelte b/src/lib/cards/NearToMeCard.svelte index 8db6be1..dbd5b9c 100644 --- a/src/lib/cards/NearToMeCard.svelte +++ b/src/lib/cards/NearToMeCard.svelte @@ -5,13 +5,14 @@ import type { CardConfig } from "./Card.types"; import type { NearestStationResponse } from "@owlboard/ts-types"; import { uuid } from "$lib/stores/uuid"; - import { location } from "$lib/stores/location"; + import { preferences } from "$lib/stores/preferences"; import InLineLoading from "$lib/navigation/InLineLoading.svelte"; import { apiGet } from "$lib/scripts/apiFetch"; import { onMount } from "svelte"; import { nearToMeCache } from "$lib/stores/nearToMeCache"; import LinkButton from "$lib/buttons/LinkButton.svelte"; import ScriptButton from "$lib/buttons/ScriptButton.svelte"; + import { togglePreference } from "$lib/scripts/preferenceUtil"; let errorMessage: string; let stations: NearestStationResponse[] = []; @@ -26,8 +27,8 @@ refreshing: false, }; - function turnOnLocation() { - location.set(true); + function turnOnLocation(): void { + togglePreference("location", true); getCurrentLocation(); toast.success("Done\nTo disable location, go to settings"); } @@ -49,7 +50,7 @@ } onMount(() => { - if ($location) { + if ($preferences.location) { if (!$uuid || $uuid === "null") { errorMessage = "Register to use this feature"; } else { @@ -70,7 +71,7 @@
{#if !$uuid || $uuid === "null"} - {:else if $location} + {:else if $preferences.location} {#if !stations.length} {#if errorMessage}

{errorMessage}

diff --git a/src/lib/cards/QuickLinkCard.svelte b/src/lib/cards/QuickLinkCard.svelte index d961fb7..08603e2 100644 --- a/src/lib/cards/QuickLinkCard.svelte +++ b/src/lib/cards/QuickLinkCard.svelte @@ -1,7 +1,7 @@ - {#if $ql.length === 0} + {#if qlData.length === 0}

Click the + button to add links

{/if}
diff --git a/src/lib/scripts/preferenceUtil.ts b/src/lib/scripts/preferenceUtil.ts new file mode 100644 index 0000000..65628ec --- /dev/null +++ b/src/lib/scripts/preferenceUtil.ts @@ -0,0 +1,9 @@ +import type { Preferences } from "$lib/stores/preferences"; +import { preferences } from "$lib/stores/preferences"; + +export function togglePreference(key: K, value: boolean): void { + preferences.update(p => ({ + ...p, + [key]: value, + })); +} \ No newline at end of file diff --git a/src/routes/more/settings/+page.svelte b/src/routes/more/settings/+page.svelte index ab66fa1..e512492 100644 --- a/src/routes/more/settings/+page.svelte +++ b/src/routes/more/settings/+page.svelte @@ -1,21 +1,31 @@ - @@ -30,7 +40,7 @@

Use your location to quickly check departure boards near you

- +
@@ -40,7 +50,7 @@

- +