debug: Add console logs to investigate playlist switching delay - Add logging to track playlist selection and change detection - Remove isInitialLoad condition that might block playlist changes - Optimize initial load to prevent conflicts with playlist switching - Temporary debugging to identify timing issues

This commit is contained in:
Geert Rademakes 2025-08-06 10:49:31 +02:00
parent 9268a4635f
commit 57c1047357
2 changed files with 10 additions and 4 deletions

View File

@ -154,6 +154,7 @@ export default function RekordboxReader() {
}, [currentPlaylist, playlists, navigate, xmlLoading]);
const handlePlaylistSelect = (name: string) => {
console.log('Playlist selected:', name);
setSelectedSong(null); // Clear selected song when changing playlists
if (name === "All Songs") {
navigate("/");

View File

@ -125,9 +125,12 @@ export const usePaginatedSongs = (options: UsePaginatedSongsOptions = {}) => {
setIsInitialLoad(true);
}, [initialSearch, cleanup]);
// Initial load
// Initial load - only run once when the hook is first created
useEffect(() => {
loadPage(1);
// Only load if we haven't loaded anything yet
if (songs.length === 0 && !loading) {
loadPage(1);
}
// Cleanup on unmount
return () => {
@ -137,7 +140,9 @@ export const usePaginatedSongs = (options: UsePaginatedSongsOptions = {}) => {
// Handle playlist changes
useEffect(() => {
if (!isInitialLoad && previousPlaylistRef.current !== playlistName) {
if (previousPlaylistRef.current !== playlistName) {
console.log('Playlist change detected:', previousPlaylistRef.current, '->', playlistName);
// Update refs
currentPlaylistRef.current = playlistName;
currentSearchQueryRef.current = searchQuery;
@ -152,7 +157,7 @@ export const usePaginatedSongs = (options: UsePaginatedSongsOptions = {}) => {
// Load immediately without setTimeout
loadPage(1, initialSearch, playlistName);
}
}, [playlistName, isInitialLoad, initialSearch, loadPage]);
}, [playlistName, initialSearch, loadPage]);
return {
songs,