From ff6b512340b9ad0be412919895c3608768b285d7 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sat, 12 Mar 2022 04:05:37 -0800 Subject: [PATCH] Adjust genre list context menu play (#239) - Increase request size from 100 -> 500 - Use totalSongs count to determine when to stop (navidrome) --- src/api/api.ts | 8 +++++++- src/components/shared/ContextMenu.tsx | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/api/api.ts b/src/api/api.ts index 1d27d2a..a4b3bd9 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -603,6 +603,7 @@ export const getSongsByGenre = async ( offset: number; musicFolderId?: string | number; recursive?: boolean; + totalSongs: number; }, recursiveData: any[] = [] ) => { @@ -617,7 +618,11 @@ export const getSongsByGenre = async ( }, }) .then((res) => { - if (!res.data.songsByGenre.song || res.data.songsByGenre.song.length === 0) { + if ( + !res.data.songsByGenre.song || + res.data.songsByGenre.song.length === 0 || + options.totalSongs <= 0 + ) { // Flatten and return once there are no more albums left const flattenedSongs = _.flatten(recursiveData); @@ -637,6 +642,7 @@ export const getSongsByGenre = async ( offset: options.offset + options.size, musicFolderId: options.musicFolderId, recursive: true, + totalSongs: options.totalSongs - options.size, }, recursiveData ); diff --git a/src/components/shared/ContextMenu.tsx b/src/components/shared/ContextMenu.tsx index d1a1af0..cdaccfe 100644 --- a/src/components/shared/ContextMenu.tsx +++ b/src/components/shared/ContextMenu.tsx @@ -241,9 +241,10 @@ export const GlobalContextMenu = () => { type: 'byGenre', genre: multiSelect.selected[i].title, musicFolderId: (folder.applied.music || folder.applied.albums) && folder.musicFolder, - size: 100, + size: 500, offset: 0, recursive: true, + totalSongs: multiSelect.selected[i]?.songCount, }, }) ); @@ -369,9 +370,10 @@ export const GlobalContextMenu = () => { type: 'byGenre', genre: multiSelect.selected[i].title, musicFolderId: (folder.applied.album || folder.applied.artist) && folder.musicFolder, - size: 100, + size: 500, offset: 0, recursive: true, + totalSongs: multiSelect.selected[i]?.songCount, }, }) );