Skip to content

Create LibraryAPI instead of useLibraryStore#960

Merged
martpie merged 2 commits intoless-zustandfrom
library-api
Apr 2, 2026
Merged

Create LibraryAPI instead of useLibraryStore#960
martpie merged 2 commits intoless-zustandfrom
library-api

Conversation

@martpie
Copy link
Copy Markdown
Owner

@martpie martpie commented Apr 2, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 2, 2026 13:48
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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 LibraryAPI and PlaylistsAPI modules (and update SettingsAPI usage) to replace src/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 .po files 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.

Comment thread src/api/LibraryAPI.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@martpie martpie merged commit a7dcb64 into less-zustand Apr 2, 2026
1 check failed
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.

2 participants