feat: persist watchlist and bridge filter/sort preferences across sessions - #25
Merged
Meshmulla merged 1 commit intoJul 22, 2026
Conversation
…sions - Migrate useWatchlist from React context + raw localStorage to a Zustand persist store (src/stores/watchlistStore.ts) backed by the namespaced key swipely:watchlist (v1). Supports legacy key migration (swipely.watchlists.v1), schema normalization, and graceful handling of corrupt or outdated persisted data. - Add src/stores/bridgeFilterSortStore.ts: Zustand persist store for bridge status filter and sort-by preferences, namespaced under swipely:bridge-filter-sort (v1), with validation guards that fall back to safe defaults on unknown/corrupt shapes. - Update BridgeFilterSort component to read from and write to the bridgeFilterSortStore when no controlled props are supplied; controlled usage continues to work via the existing prop API. - Wire applyBridgeFilterSort into Bridges.tsx so the persisted filter/sort state is applied to the bridge list on every render. - Refactor useWatchlist hook to delegate to useWatchlistStore; preserve WatchlistProvider as a no-op pass-through for call-site compatibility. - Export both new stores and their helpers from src/stores/index.ts. - Add/update unit tests for both stores covering: rehydration across restarts, graceful corrupt-data handling, legacy key migration, clear clears persisted state, and invalid value guards.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12
Summary
Implements full localStorage persistence for the watchlist and bridge filter/sort state so returning users no longer need to re-apply preferences on every visit.
Changes
src/stores/watchlistStore.ts (new)
src/stores/bridgeFilterSortStore.ts (new)
src/hooks/useWatchlist.ts
src/components/BridgeFilterSort.tsx
src/pages/Bridges.tsx
src/stores/index.ts
Tests
Acceptance Criteria
CI Validation