Create LibraryAPI instead of useLibraryStore#960
Merged
martpie merged 2 commits intoless-zustandfrom Apr 2, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors library/playlist/settings side-effect logic out of Zustand stores into dedicated API modules under src/api, leaving a slim Zustand useLibraryStore for UI state only. It updates routes/components/hooks to call the new APIs directly and refreshes Lingui translation source references accordingly.
Changes:
- Introduce
LibraryAPIandPlaylistsAPImodules (and updateSettingsAPIusage) to replacesrc/stores/*action modules. - Replace the previous “library store with embedded api” pattern with a minimal Zustand store in
src/lib/store.ts. - Update multiple routes/components/hooks and
.pofiles to use the new module paths and extracted messages.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/api/LibraryAPI.ts | New module encapsulating library operations (scan/reset/search/etc.) using useLibraryStore.setState. |
| src/api/PlaylistsAPI.ts | New module encapsulating playlist operations (create/rename/remove/reorder/etc.). |
| src/api/SettingsAPI.ts | Switches library autorefresh trigger to call LibraryAPI.scan() directly. |
| src/lib/store.ts | New minimal Zustand store for library UI state (search/refresh/progress/status). |
| src/stores/useLibraryStore.ts (deleted) | Removes prior store that mixed state + imperative API methods. |
| src/stores/store-helpers.ts (deleted) | Removes Zustand createStore helper (devtools wrapper). |
| src/routes/settings.library.tsx | Migrates library actions to LibraryAPI and store import to src/lib/store. |
| src/routes/tracks.$trackID.tsx | Migrates track metadata update to LibraryAPI.updateTrackMetadata. |
| src/routes/playlists.tsx | Switches import to src/api/PlaylistsAPI. |
| src/routes/playlists.$playlistID.tsx | Switches playlist actions to PlaylistsAPI and store import to src/lib/store. |
| src/routes/__root.tsx | Switches import to src/api/SettingsAPI. |
| src/routes/settings.ui.tsx | Switches import to src/api/SettingsAPI. |
| src/routes/settings.audio.tsx | Switches import to src/api/SettingsAPI. |
| src/routes/settings.about.tsx | Switches import to src/api/SettingsAPI. |
| src/hooks/useGlobalTrackListStatus.ts | Uses LibraryAPI.setTracksStatus instead of store API hook. |
| src/hooks/useFilteredTracks.ts | Updates store import to src/lib/store. |
| src/components/TrackList.tsx | Uses LibraryAPI/PlaylistsAPI instead of store-based APIs. |
| src/components/Search.tsx | Uses LibraryAPI.search and the new store import. |
| src/components/Navigation.tsx | Updates store import to src/lib/store. |
| src/components/LibraryEvents.tsx | Uses LibraryAPI.setRefresh directly for scan progress events. |
| src/components/DropzoneImport.tsx | Uses LibraryAPI.addLibraryFolders / LibraryAPI.scan. |
| src/components/AppEvents.tsx | Switches import to src/api/SettingsAPI. |
| src/components/TrackListStates.tsx | Updates store import to src/lib/store. |
| src/translations/en.po | Updates extracted message references from src/stores/* to src/api/*. |
| src/translations/es.po | Updates extracted message references from src/stores/* to src/api/*. |
| src/translations/fr.po | Updates extracted message references from src/stores/* to src/api/*. |
| src/translations/ja.po | Updates extracted message references from src/stores/* to src/api/*. |
| src/translations/ru.po | Updates extracted message references from src/stores/* to src/api/*. |
| src/translations/zh-CN.po | Updates extracted message references from src/stores/* to src/api/*. |
| src/translations/zh-TW.po | Updates extracted message references from src/stores/* to src/api/*. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
No description provided.