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:
parent
9268a4635f
commit
57c1047357
@ -154,6 +154,7 @@ export default function RekordboxReader() {
|
|||||||
}, [currentPlaylist, playlists, navigate, xmlLoading]);
|
}, [currentPlaylist, playlists, navigate, xmlLoading]);
|
||||||
|
|
||||||
const handlePlaylistSelect = (name: string) => {
|
const handlePlaylistSelect = (name: string) => {
|
||||||
|
console.log('Playlist selected:', name);
|
||||||
setSelectedSong(null); // Clear selected song when changing playlists
|
setSelectedSong(null); // Clear selected song when changing playlists
|
||||||
if (name === "All Songs") {
|
if (name === "All Songs") {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
|
|||||||
@ -125,9 +125,12 @@ export const usePaginatedSongs = (options: UsePaginatedSongsOptions = {}) => {
|
|||||||
setIsInitialLoad(true);
|
setIsInitialLoad(true);
|
||||||
}, [initialSearch, cleanup]);
|
}, [initialSearch, cleanup]);
|
||||||
|
|
||||||
// Initial load
|
// Initial load - only run once when the hook is first created
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadPage(1);
|
// Only load if we haven't loaded anything yet
|
||||||
|
if (songs.length === 0 && !loading) {
|
||||||
|
loadPage(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Cleanup on unmount
|
// Cleanup on unmount
|
||||||
return () => {
|
return () => {
|
||||||
@ -137,7 +140,9 @@ export const usePaginatedSongs = (options: UsePaginatedSongsOptions = {}) => {
|
|||||||
|
|
||||||
// Handle playlist changes
|
// Handle playlist changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isInitialLoad && previousPlaylistRef.current !== playlistName) {
|
if (previousPlaylistRef.current !== playlistName) {
|
||||||
|
console.log('Playlist change detected:', previousPlaylistRef.current, '->', playlistName);
|
||||||
|
|
||||||
// Update refs
|
// Update refs
|
||||||
currentPlaylistRef.current = playlistName;
|
currentPlaylistRef.current = playlistName;
|
||||||
currentSearchQueryRef.current = searchQuery;
|
currentSearchQueryRef.current = searchQuery;
|
||||||
@ -152,7 +157,7 @@ export const usePaginatedSongs = (options: UsePaginatedSongsOptions = {}) => {
|
|||||||
// Load immediately without setTimeout
|
// Load immediately without setTimeout
|
||||||
loadPage(1, initialSearch, playlistName);
|
loadPage(1, initialSearch, playlistName);
|
||||||
}
|
}
|
||||||
}, [playlistName, isInitialLoad, initialSearch, loadPage]);
|
}, [playlistName, initialSearch, loadPage]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
songs,
|
songs,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user