Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

refactor(journey): read the stored dismissed suggestions as the list they are written as

Maurice36f1b5b7d925
diff --git a/client/src/pages/journey/useJourney.ts b/client/src/pages/journey/useJourney.ts
index fe90d61f5..c24f5086d 100644
--- a/client/src/pages/journey/useJourney.ts
+++ b/client/src/pages/journey/useJourney.ts
@@ -11,24 +11,11 @@ function dismissedSuggestionsKey(userId: number | undefined): string {
return `trek:journey:dismissed-suggestions:v1:${userId ?? 'anonymous'}`
}
+/** The trips this user put away, as stored here; anything unreadable reads as none. */
function readDismissedSuggestions(userId: number | undefined): Set<number> {
try {
const value: unknown = JSON.parse(window.localStorage.getItem(dismissedSuggestionsKey(userId)) || '[]')
- if (!Array.isArray(value)) return new Set()
-
- const dismissed = new Set<number>()
- for (const item of value) {
- if (Number.isInteger(item)) {
- dismissed.add(item)
- continue
- }
- if (!item || typeof item !== 'object') {
- continue
- }
- const record = item as { id?: unknown; dismissedAt?: unknown }
- if (typeof record.id === 'number' && Number.isInteger(record.id)) dismissed.add(record.id)
- }
- return dismissed
+ return new Set(Array.isArray(value) ? value.filter((id): id is number => Number.isInteger(id)) : [])
} catch {
return new Set()
}