Add QuickLinks based on 'frecency' pattern
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
<script lang="ts">
|
||||
import LocationBoardCard from '$lib/components/ui/cards/LocationBoardCard.svelte';
|
||||
import NearbyStationsCard from '$lib/components/ui/cards/NearbyStationsCard.svelte';
|
||||
import QuickLinksCard from '$lib/components/ui/cards/QuickLinksCard.svelte';
|
||||
</script>
|
||||
|
||||
<div class="card-container">
|
||||
<LocationBoardCard />
|
||||
<NearbyStationsCard />
|
||||
<QuickLinksCard />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
import { quickLinks } from '$lib/quick-links.svelte';
|
||||
|
||||
let { data } = $props();
|
||||
|
||||
// Update 'QuickLinks'
|
||||
$effect(() => {
|
||||
if (data.BoardLocation) {
|
||||
const id = data.BoardLocation?.c ?? data.BoardLocation?.t;
|
||||
if (id) {
|
||||
// Untrack, as we do not need to handle changes to quickLinks - this is WRITE_ONLY
|
||||
untrack(() => {
|
||||
quickLinks.recordVisit(id);
|
||||
console.log(`QuickLink visit recorded: ${JSON.stringify(data.BoardLocation)}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<section>Live board are not yet implemented on the server</section>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -18,11 +18,13 @@ export const load: PageLoad = async ({ url }) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (locId) {
|
||||
const location = LOCATIONS.find(locId);
|
||||
let BoardLocation;
|
||||
|
||||
if (location) {
|
||||
title = location.n || location.t;
|
||||
if (locId) {
|
||||
BoardLocation = LOCATIONS.find(locId);
|
||||
|
||||
if (BoardLocation) {
|
||||
title = BoardLocation.n || BoardLocation.t || 'Live Arr/Dep';
|
||||
} else {
|
||||
error(404, {
|
||||
message: `Location (${locId.toUpperCase()}) not found`,
|
||||
@@ -32,6 +34,6 @@ export const load: PageLoad = async ({ url }) => {
|
||||
}
|
||||
return {
|
||||
title,
|
||||
location
|
||||
BoardLocation
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user