faster fetching for artist albums

This commit is contained in:
2026-02-22 20:42:32 -05:00
parent ab5f690c05
commit bd9652b378
3 changed files with 83 additions and 30 deletions
@@ -61,6 +61,14 @@ export class LibraryController implements ReactiveController {
return libraryStore.getAlbumsByArtist(artistID);
}
getAlbumsByArtistNameCached(
artistName: string,
): library.Album[] | null {
return libraryStore.getAlbumsByArtistNameCached(
artistName,
);
}
get cachedTracks(): library.Track[] | null {
return libraryStore.getCachedTracks();
}
+18
View File
@@ -130,6 +130,24 @@ class LibraryStore {
return GetAlbumsByArtist(artistID);
}
/**
* Returns albums filtered by artist name from
* the in-memory cache, or null if the cache is
* not populated. This provides an instant
* result when the all-albums list has already
* been loaded (e.g. the user visited the albums
* view first).
*/
getAlbumsByArtistNameCached(
artistName: string,
): library.Album[] | null {
if (this.albums === null) return null;
return this.albums.filter(
(a) => a.ArtistName === artistName,
);
}
// ===================================================================
// STATE ACCESSORS
// Synchronous access for controllers that need current cached values.