Skip to content

perf: optimize LibraryScreen state management and recompositions#1193

Merged
theovilardo merged 1 commit intomasterfrom
fix/global-recomp-libraryscreen
Feb 22, 2026
Merged

perf: optimize LibraryScreen state management and recompositions#1193
theovilardo merged 1 commit intomasterfrom
fix/global-recomp-libraryscreen

Conversation

@theovilardo
Copy link
Copy Markdown
Owner

  • State Management:
    • Introduce LibraryScreenPlayerProjection data class to encapsulate only the necessary UI state from PlayerViewModel, reducing unnecessary recompositions.
    • Use distinctUntilChanged() and map on state flows to ensure the UI only reacts to relevant data changes.
    • Refactor BackHandler and loading overlay logic to use memoized state collectors (canNavigateBackInFolders, isLibraryContentEmpty).
  • Performance:
    • Replace broad playerUiState collection with a scoped projection within the Scaffold content.
    • Optimize empty state detection by combining allSongsFlow, albumsFlow, and artistsFlow reactively.
  • UI/UX:
    • Ensure loading overlays for AI metadata generation and library syncing respect the optimized state projections.
    • Clean up redundant state declarations and unused imports.

- **State Management**:
    - Introduce `LibraryScreenPlayerProjection` data class to encapsulate only the necessary UI state from `PlayerViewModel`, reducing unnecessary recompositions.
    - Use `distinctUntilChanged()` and `map` on state flows to ensure the UI only reacts to relevant data changes.
    - Refactor `BackHandler` and loading overlay logic to use memoized state collectors (`canNavigateBackInFolders`, `isLibraryContentEmpty`).
- **Performance**:
    - Replace broad `playerUiState` collection with a scoped projection within the `Scaffold` content.
    - Optimize empty state detection by combining `allSongsFlow`, `albumsFlow`, and `artistsFlow` reactively.
- **UI/UX**:
    - Ensure loading overlays for AI metadata generation and library syncing respect the optimized state projections.
    - Clean up redundant state declarations and unused imports.
@theovilardo theovilardo merged commit c066ced into master Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant