perf: Remove unnecessary delays in playlist switching and infinite scroll - Remove setTimeout delay in playlist change handler - Reduce infinite scroll trigger delay from 1000ms to 100ms - Improve responsiveness when switching playlists and scrolling - Fixes 1-second delay between URL change and actual loading

This commit is contained in:
Geert Rademakes 2025-08-06 10:47:37 +02:00
parent e8bb2a4326
commit 9268a4635f
2 changed files with 3 additions and 5 deletions

View File

@ -257,7 +257,7 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
// Reset the flag after a short delay to prevent multiple triggers
timeoutRef.current = setTimeout(() => {
isTriggeringRef.current = false;
}, 1000);
}, 100);
}
},
{

View File

@ -149,10 +149,8 @@ export const usePaginatedSongs = (options: UsePaginatedSongsOptions = {}) => {
setCurrentPage(1);
setSearchQuery(initialSearch);
setError(null);
// Use setTimeout to avoid the dependency issue
setTimeout(() => {
loadPage(1, initialSearch, playlistName);
}, 0);
// Load immediately without setTimeout
loadPage(1, initialSearch, playlistName);
}
}, [playlistName, isInitialLoad, initialSearch, loadPage]);