Skip to content

Commit e5fef72

Browse files
refactor: update catalog store implementation and integrate with search results component
- Introduced context-based usage for the catalog store. - Updated search results component to utilize the new catalog store structure.
1 parent 6b057c3 commit e5fef72

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/lib/components/search/results.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<script lang="ts">
22
import Table from "$lib/components/table/table.svelte";
33
4-
import { catalog } from "$lib/stores/catalog.svelte";
4+
import { Catalog } from "$lib/stores/catalog.svelte";
55
66
import { mapConfig } from "$lib/utilities/catalog";
77
8+
const catalog = Catalog.use();
9+
810
const config = $derived(mapConfig(catalog, "Search Results", "Search all stores..."));
911
</script>
1012

src/lib/stores/catalog.svelte.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { setContext, getContext } from "svelte";
2+
13
import SearchWorker from "$lib/workers/search.worker?worker";
24

35
import type { Store } from "$lib/types/store";
@@ -6,7 +8,7 @@ import type { Status } from "$lib/types/status";
68
import { SortStateSchema, type SortState } from "$lib/types/table";
79
import type { WorkerToMainMessage } from "$lib/types/worker";
810

9-
export class Catalog {
11+
export class CatalogStore {
1012
status = $state<Status>("pending");
1113
count = $state(0);
1214
total = $state(0);
@@ -127,4 +129,9 @@ export class Catalog {
127129
}
128130
}
129131

130-
export const catalog = new Catalog();
132+
const key = Symbol("catalog");
133+
134+
export const Catalog = {
135+
init: () => setContext(key, new CatalogStore()),
136+
use: () => getContext<CatalogStore>(key)
137+
}

src/routes/(app)/+layout.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<script lang="ts">
22
import Navbar from "$lib/components/layout/navbar.svelte";
3+
4+
import { Catalog } from "$lib/stores/catalog.svelte";
5+
6+
Catalog.init();
37
48
let { children } = $props();
59
</script>

static/version.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"number": "0.4.23",
3-
"lastUpdated": "2026-01-05T19:38:47.550654+00:00",
4-
"sheetLastFetched": "2026-01-05T19:38:47.550654+00:00",
2+
"number": "0.4.30",
3+
"lastUpdated": "2026-01-07T15:44:37.344082+00:00",
4+
"sheetLastFetched": "2026-01-07T15:44:37.344082+00:00",
55
"sheetLastUpdated": "2025-12-19T06:00:00+00:00"
66
}

0 commit comments

Comments
 (0)