feat(13-02): add library filter dropdown and wire all views to respect active filter

- Add selectedLibraryId state + ByLibrary conditional calls to library-store
- Add library filter pass-through methods to library-controller
- Create library-filter dropdown component in top bar
- Wire genre-details, cover-grid, artists-view, genres-view to use ByLibrary queries
- Update album-selection helper to respect library filter
- Regenerate Wails bindings for new ByLibrary methods
- Search remains client-side (automatically filtered by loaded data)
- Playlists remain unfiltered (use separate playlist store)
This commit is contained in:
2026-03-16 09:41:27 -04:00
parent 5f7de5060a
commit 42b8cf9f52
16 changed files with 492 additions and 51 deletions
@@ -1,4 +1,8 @@
import { GetAlbumTracks } from '@go/library/Library';
import {
GetAlbumTracks,
GetAlbumTracksByLibrary,
} from '@go/library/Library';
import { libraryStore } from '@store/library-store';
import type { library } from '@go/models';
import type { CoverArtUrls } from '@components/track-details/track-details.js';
@@ -43,6 +47,21 @@ export class AlbumSelectionManager {
this.albumFilePathCache.clear();
}
/**
* Fetch album tracks respecting the active
* library filter.
*/
private fetchAlbumTracks(
albumId: number,
): Promise<library.Track[]> {
const libId =
libraryStore.getSelectedLibraryId();
return libId !== null
? GetAlbumTracksByLibrary(albumId, libId)
: GetAlbumTracks(albumId);
}
// ================================================================
// Album selection helpers
// ================================================================
@@ -134,9 +153,8 @@ export class AlbumSelectionManager {
album: library.Album,
): Promise<string[]> {
try {
const tracks = await GetAlbumTracks(
album.ID,
);
const tracks =
await this.fetchAlbumTracks(album.ID);
return tracks.map((t) => t.FilePath);
} catch (error) {
@@ -174,9 +192,10 @@ export class AlbumSelectionManager {
if (!album) continue;
try {
const tracks = await GetAlbumTracks(
album.ID,
);
const tracks =
await this.fetchAlbumTracks(
album.ID,
);
// Only store if still selected.
if (selectedAlbums.has(album.ID)) {
@@ -11,7 +11,10 @@ import type {
VisibilityChangedEvent,
} from '@lit-labs/virtualizer';
import { grid } from '@lit-labs/virtualizer/layouts/grid.js';
import { GetAlbumTracks } from '@go/library/Library';
import {
GetAlbumTracks,
GetAlbumTracksByLibrary,
} from '@go/library/Library';
import { library } from '@go/models';
import { LibraryController } from '@store/controllers/library-controller';
import { SearchController } from '@store/controllers/search-controller';
@@ -973,9 +976,15 @@ export class CoverGrid
this.lastSelectedTrackIndex = null;
try {
const tracks = await GetAlbumTracks(
album.ID,
);
const libId =
this.libraryCtrl.selectedLibraryId;
const tracks = libId !== null
? await GetAlbumTracksByLibrary(
album.ID,
libId,
)
: await GetAlbumTracks(album.ID);
if (this.expandedAlbumId === album.ID) {
this.expandedTracks = tracks;