add better handler for large fetch confirmation for songs

This commit is contained in:
jeffvli
2025-12-02 00:59:13 -08:00
parent 6d8947fe74
commit 2c026837e8
2 changed files with 16 additions and 8 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
"downloadStarted": "started download of {{count}} items",
"editPlaylist": "edit $t(entity.playlist_one)",
"goToPage": "go to page",
"largeFetch": "this action will attempt to fetch {{count}} items from your server",
"largeFetch": "this action will make {{count}} network requests to your server",
"moveToNext": "move to next",
"moveToBottom": "move to bottom",
"moveToTop": "move to top",
@@ -375,9 +375,21 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
})) as number;
totalCount = countResult || 0;
// Check if we need confirmation
if (totalCount > queueFetchConfirmThreshold) {
const confirmed = await confirmLargeFetch(totalCount);
const allResults: Song[] | string[] = [];
const pageSize = 500;
// Calculate the number of fetches needed
let numberOfFetches = 0;
if (itemType === LibraryItem.SONG) {
// For songs, the number of fetches is based on pagination
numberOfFetches = Math.ceil(totalCount / pageSize);
} else {
const paginationFetches = Math.ceil(totalCount / pageSize);
numberOfFetches = paginationFetches + totalCount;
}
if (numberOfFetches > queueFetchConfirmThreshold) {
const confirmed = await confirmLargeFetch(numberOfFetches);
if (!confirmed) {
return;
}
@@ -411,10 +423,6 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
});
}, 2000),
};
// Paginate through all items to collect IDs
const allResults: Song[] | string[] = [];
const pageSize = 500; // Fetch in chunks
let startIndex = 0;
while (startIndex < totalCount) {