Fix library selection state for single-library users #4686
Merged
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.
Description
Fixes a state synchronization bug where users with a single library or changing library access see no content due to stale
selectedLibrariesin localStorage/Redux state.The issue occurs when:
selectedLibrariescontaining library IDs they no longer have access to (e.g., after removing libraries or switching accounts)LibrarySelectorcomponent doesn't render for single-library users, providing no UI to fix the selectionRelated Issues
Fixes #4553
Fixes #4508
Fixes #4569
Type of Change
Checklist
Please review and check all that apply:
How to Test
Prerequisites:
Test Scenario 1: Single library with stale state
localStorage.setItem('state', JSON.stringify({library: {userLibraries: [{id: 1, name: "Music Library"}], selectedLibraries: [2]}}))Test Scenario 2: Switching from multiple to single library
Test Scenario 3: Account switching
Additional Notes
Implementation:
selectedLibrarieswhenSET_USER_LIBRARIESis dispatched, filtering out invalid IDs and resetting to empty array for single-library usersgetSelectedLibraries()to check against current user libraries before applying filtersImpact: