-
Notifications
You must be signed in to change notification settings - Fork 0
Store user preferences (filters) in local storage #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store user preferences (filters) in local storage #1
Conversation
…orage Co-authored-by: wcypierre <1132980+wcypierre@users.noreply.github.com>
…nces Co-authored-by: wcypierre <1132980+wcypierre@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements localStorage persistence for user filter preferences (sort field, sort direction, and state filter) to improve user experience by remembering their selections across page reloads.
Key Changes
- New PreferencesService: Manages localStorage operations with validation and error handling for user preferences
- Type-safe sorting: Introduced
SortFieldunion type to restrict valid sort values - AppComponent integration: Property setters automatically save preferences; preferences are loaded on component initialization
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/app/preferences.service.ts | New service handling localStorage read/write operations with validation for corrupted data |
| frontend/src/app/preferences.service.spec.ts | Comprehensive test suite covering service methods, validation, and edge cases |
| frontend/src/app/app.component.ts | Integration of PreferencesService with property getters/setters and initialization logic |
| frontend/src/app/app.component.html | Updated filter dropdown to use new onFilterStateChange method and one-way binding |
| frontend/package-lock.json | Automatic dependency cleanup (optional dependencies reorganization) |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const STORAGE_KEY = 'storm_preferences'; | ||
|
|
||
| const VALID_SORT_FIELDS: SortField[] = ['State', 'TimeAdded', 'Progress', 'ETA', 'Name', 'TotalSize', 'Ratio', 'SeedingTime']; | ||
| const VALID_FILTER_STATES: (State | null)[] = [null, 'Active', 'Queued', 'Downloading', 'Seeding', 'Paused', 'Error']; |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The VALID_FILTER_STATES array is missing some State values that exist in the State type. The State type includes 'Allocating', 'Checking', and 'Moving', but these are not present in the validation array. This means if a user saves preferences with these states, they will be reset to null on load. Consider including all valid State values in the validation array:
const VALID_FILTER_STATES: (State | null)[] = [null, 'Active', 'Allocating', 'Checking', 'Queued', 'Downloading', 'Seeding', 'Paused', 'Error', 'Moving'];| const VALID_FILTER_STATES: (State | null)[] = [null, 'Active', 'Queued', 'Downloading', 'Seeding', 'Paused', 'Error']; | |
| const VALID_FILTER_STATES: (State | null)[] = [null, 'Active', 'Allocating', 'Checking', 'Queued', 'Downloading', 'Seeding', 'Paused', 'Error', 'Moving']; |
| constructor(private api: ApiService, private focus: FocusService, private dialogService: DialogService, private preferences: PreferencesService) { | ||
| // Load saved preferences | ||
| const savedPrefs = this.preferences.load(); | ||
| this._sortByField = savedPrefs.sortByField; | ||
| this._sortReverse = savedPrefs.sortReverse; | ||
|
|
||
| this.get$ = new BehaviorSubject<OptionalState>(savedPrefs.filterState); | ||
| this.refreshInterval(2000); | ||
| } |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new preference-related functionality in AppComponent lacks test coverage. Consider adding tests to verify:
- Preferences are loaded correctly on initialization
- Property setters (
sortByField,sortReverse) properly save preferences - The
onFilterStateChangemethod correctly updates both the BehaviorSubject and saves preferences - Integration with PreferencesService works as expected
User filter preferences (sort field, sort direction, state filter) are now persisted to localStorage and restored on page load.
Changes
PreferencesService- Handles localStorage read/write with validation for corrupted/invalid dataAppComponentintegration - Loads preferences on init, saves on change via property settersSortFieldunion type restricting valid sort valuesStored Preferences
Screenshot
After selecting filters and refreshing the page, preferences are restored:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
accounts.google.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3863 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-75936549 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2344358832365387046,1266882387370985235,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --user-data-dir=/tmp/karma-75936549 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications http://localhost:9876/?id=75936549 --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=4023 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-57689991 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15911362977511374243,1810406567735880517,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)android.clients.google.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=4023 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-57689991 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15911362977511374243,1810406567735880517,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --user-data-dir=/tmp/karma-57689991 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications http://localhost:9876/?id=57689991 --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=4198 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-95066792 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4025110524598156603,14072393095302940932,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)clients2.google.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3863 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-75936549 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2344358832365387046,1266882387370985235,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --user-data-dir=/tmp/karma-75936549 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications http://localhost:9876/?id=75936549 --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=4023 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-57689991 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15911362977511374243,1810406567735880517,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)clientservices.googleapis.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3863 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-75936549 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2344358832365387046,1266882387370985235,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --user-data-dir=/tmp/karma-75936549 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications http://localhost:9876/?id=75936549 --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=4023 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-57689991 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15911362977511374243,1810406567735880517,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)redirector.gvt1.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3863 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-75936549 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2344358832365387046,1266882387370985235,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --user-data-dir=/tmp/karma-75936549 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications http://localhost:9876/?id=75936549 --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=4023 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-57689991 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15911362977511374243,1810406567735880517,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)safebrowsingohttpgateway.googleapis.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3863 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-75936549 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2344358832365387046,1266882387370985235,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --user-data-dir=/tmp/karma-75936549 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications http://localhost:9876/?id=75936549 --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=4023 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-57689991 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15911362977511374243,1810406567735880517,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)www.google.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3863 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-75936549 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2344358832365387046,1266882387370985235,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --user-data-dir=/tmp/karma-75936549 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications http://localhost:9876/?id=75936549 --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=4023 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-57689991 --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15911362977511374243,1810406567735880517,262144 --disable-features=PaintHolding --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.