mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-06 20:10:12 +02:00
improve album artist favorite performance and search
This commit is contained in:
@@ -717,6 +717,8 @@ const AlbumArtistMetadataFavoriteSongs = ({ routeId }: AlbumArtistMetadataFavori
|
||||
tableColumnsData={SONG_TABLE_COLUMNS}
|
||||
/>
|
||||
</Group>
|
||||
{/* Restrict the height. Rendering all items in the DOM makes for a long delay */}
|
||||
<div style={{ height: 50 + 64 * Math.min(songs.length, 5) }}>
|
||||
<ItemTableList
|
||||
activeRowId={currentSongId}
|
||||
autoFitColumns={tableConfig.autoFitColumns}
|
||||
@@ -739,6 +741,8 @@ const AlbumArtistMetadataFavoriteSongs = ({ routeId }: AlbumArtistMetadataFavori
|
||||
overrideControls={overrideControls}
|
||||
size={tableConfig.size}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{!searchTerm.trim() && songs.length > 5 && !showAll && (
|
||||
<Group justify="center" w="100%">
|
||||
<Button onClick={() => setShowAll(true)} variant="subtle">
|
||||
|
||||
@@ -124,23 +124,12 @@ export const createFuseForLibraryItem = <T extends FuseSearchableItem>(
|
||||
});
|
||||
}
|
||||
|
||||
const sampleItem = items[0];
|
||||
|
||||
const stringKeys = Object.keys(sampleItem).filter(
|
||||
(key) =>
|
||||
typeof sampleItem[key as keyof T] === 'string' &&
|
||||
!key.startsWith('_') &&
|
||||
key !== 'id' &&
|
||||
key !== 'albumId' &&
|
||||
key !== 'streamUrl' &&
|
||||
key !== 'serverId' &&
|
||||
key !== 'ownerId',
|
||||
) as string[];
|
||||
|
||||
const stringKeys: string[] = [];
|
||||
const nestedKeys: Array<{ getFn: (item: T) => string; name: string }> = [];
|
||||
|
||||
switch (itemType) {
|
||||
case LibraryItem.ALBUM: {
|
||||
stringKeys.push('name', 'releaseType');
|
||||
nestedKeys.push(
|
||||
{
|
||||
getFn: (item) => {
|
||||
@@ -168,6 +157,7 @@ export const createFuseForLibraryItem = <T extends FuseSearchableItem>(
|
||||
}
|
||||
|
||||
case LibraryItem.ALBUM_ARTIST: {
|
||||
stringKeys.push('name');
|
||||
nestedKeys.push({
|
||||
getFn: (item) => {
|
||||
const aa = item as AlbumArtist;
|
||||
@@ -181,9 +171,10 @@ export const createFuseForLibraryItem = <T extends FuseSearchableItem>(
|
||||
case LibraryItem.ARTIST:
|
||||
case LibraryItem.GENRE:
|
||||
case LibraryItem.RADIO_STATION:
|
||||
stringKeys.push('name');
|
||||
break;
|
||||
|
||||
case LibraryItem.PLAYLIST: {
|
||||
stringKeys.push('name');
|
||||
nestedKeys.push({
|
||||
getFn: (item) => {
|
||||
const p = item as Playlist;
|
||||
@@ -196,7 +187,8 @@ export const createFuseForLibraryItem = <T extends FuseSearchableItem>(
|
||||
|
||||
case LibraryItem.PLAYLIST_SONG:
|
||||
case LibraryItem.QUEUE_SONG:
|
||||
case LibraryItem.SONG: {
|
||||
case LibraryItem.SONG:
|
||||
stringKeys.push('album', 'name');
|
||||
nestedKeys.push(
|
||||
{
|
||||
getFn: (item) => {
|
||||
@@ -215,7 +207,6 @@ export const createFuseForLibraryItem = <T extends FuseSearchableItem>(
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new Fuse(items, {
|
||||
fieldNormWeight,
|
||||
|
||||
Reference in New Issue
Block a user