mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
add better handler for large fetch confirmation for songs
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"downloadStarted": "started download of {{count}} items",
|
"downloadStarted": "started download of {{count}} items",
|
||||||
"editPlaylist": "edit $t(entity.playlist_one)",
|
"editPlaylist": "edit $t(entity.playlist_one)",
|
||||||
"goToPage": "go to page",
|
"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",
|
"moveToNext": "move to next",
|
||||||
"moveToBottom": "move to bottom",
|
"moveToBottom": "move to bottom",
|
||||||
"moveToTop": "move to top",
|
"moveToTop": "move to top",
|
||||||
|
|||||||
@@ -375,9 +375,21 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
})) as number;
|
})) as number;
|
||||||
totalCount = countResult || 0;
|
totalCount = countResult || 0;
|
||||||
|
|
||||||
// Check if we need confirmation
|
const allResults: Song[] | string[] = [];
|
||||||
if (totalCount > queueFetchConfirmThreshold) {
|
const pageSize = 500;
|
||||||
const confirmed = await confirmLargeFetch(totalCount);
|
|
||||||
|
// 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) {
|
if (!confirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -411,10 +423,6 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
});
|
});
|
||||||
}, 2000),
|
}, 2000),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Paginate through all items to collect IDs
|
|
||||||
const allResults: Song[] | string[] = [];
|
|
||||||
const pageSize = 500; // Fetch in chunks
|
|
||||||
let startIndex = 0;
|
let startIndex = 0;
|
||||||
|
|
||||||
while (startIndex < totalCount) {
|
while (startIndex < totalCount) {
|
||||||
|
|||||||
Reference in New Issue
Block a user