diff --git a/packages/backend/src/routes/playlists.ts b/packages/backend/src/routes/playlists.ts index 8ced19d..448c121 100644 --- a/packages/backend/src/routes/playlists.ts +++ b/packages/backend/src/routes/playlists.ts @@ -154,8 +154,7 @@ router.post('/reorder-move', async (req: Request, res: Response) => { if (insertIndex < 0) insertIndex = without.length; without.splice(insertIndex, 0, fromId); - console.log('[REORDER_MOVE] playlist:', playlistName, 'from:', fromId, 'to:', toId, 'baseLen:', base.length, 'orderLenBefore:', order.length, 'orderLenAfter:', without.length); - console.log('[REORDER_MOVE] sample order:', without.slice(0, 5)); + // Updated playlist order overlay node.order = without; // store full order overlay updated = true; return node; @@ -219,8 +218,7 @@ router.post('/reorder-move-many', async (req: Request, res: Response) => { // Insert block preserving relative order without.splice(insertIndex, 0, ...movingOrdered); - console.log('[REORDER_MOVE_MANY] playlist:', playlistName, 'count:', movingOrdered.length, 'to:', toId, 'baseLen:', base.length, 'orderLenBefore:', order.length, 'orderLenAfter:', without.length); - console.log('[REORDER_MOVE_MANY] sample order:', without.slice(0, 7)); + // Updated playlist order overlay for batch move node.order = without; updated = true; return node; diff --git a/packages/backend/src/routes/songs.ts b/packages/backend/src/routes/songs.ts index 3e543f9..184ebec 100644 --- a/packages/backend/src/routes/songs.ts +++ b/packages/backend/src/routes/songs.ts @@ -76,7 +76,7 @@ router.get('/playlist/*', async (req: Request, res: Response) => { const search = req.query.search as string || ''; const skip = (page - 1) * limit; - console.log(`Fetching songs for playlist "${playlistName}"... Page: ${page}, Limit: ${limit}, Search: "${search}"`); + // Fetch songs for playlist with pagination // Find the playlist recursively in the playlist structure const findPlaylistRecursively = (nodes: any[], targetName: string): any => { @@ -102,9 +102,7 @@ router.get('/playlist/*', async (req: Request, res: Response) => { } if (!playlist) { - console.log(`Playlist "${playlistName}" not found. Available playlists:`); - const allPlaylistNames = await Playlist.find({}, 'name'); - console.log(allPlaylistNames.map(p => p.name)); + // Playlist not found return res.status(404).json({ message: `Playlist "${playlistName}" not found` }); } @@ -126,8 +124,7 @@ router.get('/playlist/*', async (req: Request, res: Response) => { }; const trackIds = getAllTrackIds(playlist); - console.log(`[PLAYLIST_ORDER] ${playlistName} tracks count:`, trackIds.length); - console.log('[PLAYLIST_ORDER] first 10 ids:', trackIds.slice(0, 10)); + // Compute effective ordered track IDs if (trackIds.length === 0) { return res.json({ @@ -178,7 +175,6 @@ router.get('/playlist/*', async (req: Request, res: Response) => { const pageEnd = Math.min(pageStart + limit, trackIds.length); const pageTrackIds = trackIds.slice(pageStart, pageEnd); - console.log('[PLAYLIST_ORDER] page', page, 'limit', limit, 'slice', pageStart, pageEnd, 'ids:', pageTrackIds); const pageSongs = await Song.find({ id: { $in: pageTrackIds } }) .populate('s3File.musicFileId') .lean(); @@ -186,8 +182,6 @@ router.get('/playlist/*', async (req: Request, res: Response) => { for (const s of pageSongs) idToSong[s.id] = s; const songs = pageTrackIds.map(id => idToSong[id]).filter(Boolean); - console.log(`Found ${songs.length} songs for playlist "${playlistName}" (${totalSongs} total), ${songs.filter((s: any) => s.s3File?.hasS3File).length} with S3 files`); - res.json({ songs, pagination: { diff --git a/packages/backend/src/services/xmlService.ts b/packages/backend/src/services/xmlService.ts index be0037a..2f2a92b 100644 --- a/packages/backend/src/services/xmlService.ts +++ b/packages/backend/src/services/xmlService.ts @@ -40,7 +40,7 @@ const buildXmlNode = (node: any): any => { }; export const streamToXml = async (res: any) => { - console.log('Starting streamToXml function...'); + console.log('Starting XML export...'); // Write XML header with encoding (like master collection) res.write(''); @@ -50,9 +50,7 @@ export const streamToXml = async (res: any) => { res.write('\n '); // Start COLLECTION section - console.log('Counting songs in database...'); const songCount = await Song.countDocuments(); - console.log(`Found ${songCount} songs in database`); res.write(`\n `); // Stream songs in batches to avoid memory issues @@ -78,7 +76,6 @@ export const streamToXml = async (res: any) => { } processedSongs += songs.length; - console.log(`Streamed ${processedSongs}/${songCount} songs...`); } res.write('\n '); @@ -87,9 +84,7 @@ export const streamToXml = async (res: any) => { res.write('\n '); // Stream playlists - console.log('Fetching playlists from database...'); const playlists = await Playlist.find({}).lean(); - console.log(`Found ${playlists.length} playlists in database`); // Write ROOT node with correct Count res.write(`\n `); @@ -103,6 +98,7 @@ export const streamToXml = async (res: any) => { res.write('\n'); res.end(); + console.log('XML export completed.'); }; const streamPlaylistNodeFull = async (res: any, node: any) => { diff --git a/packages/frontend/src/components/PaginatedSongList.tsx b/packages/frontend/src/components/PaginatedSongList.tsx index 59994e4..cb81877 100644 --- a/packages/frontend/src/components/PaginatedSongList.tsx +++ b/packages/frontend/src/components/PaginatedSongList.tsx @@ -298,27 +298,16 @@ export const PaginatedSongList: React.FC = memo(({ } } catch {} } - if (!fromId && !multiIds) { - console.debug('[Reorder] missing fromId'); - return; - } + if (!fromId && !multiIds) return; const fromIndex = fromId ? songs.findIndex(s => s.id === fromId) : -1; const toIndex = index; - if (fromIndex < 0 || toIndex < 0) { - console.debug('[Reorder] invalid indexes', { fromIndex, toIndex }); - return; - } - if (fromIndex === toIndex) { - console.debug('[Reorder] same index drop'); - return; - } + if (fromIndex < 0 || toIndex < 0) return; + if (fromIndex === toIndex) return; const toId = songs[index].id; // If multiple, move block; else move single if (multiIds && multiIds.length > 0) { - console.debug('[Reorder] move many request', { playlist: currentPlaylist, fromIds: multiIds, toId }); await api.moveTracksInPlaylist(currentPlaylist, multiIds, toId); } else { - console.debug('[Reorder] move request', { playlist: currentPlaylist, fromId, toId }); await api.moveTrackInPlaylist(currentPlaylist, fromId!, toId); } await onReorder(songs.map(s => s.id)); // trigger refresh via parent @@ -326,10 +315,9 @@ export const PaginatedSongList: React.FC = memo(({ setIsReorderDragging(false); }} onRowDragStartCapture={(e: React.DragEvent) => { - // Provide a simple id for intra-list reorder + // Provide a simple id for intra-list reorder if (!currentPlaylist || selectedSongs.size > 0) return; e.dataTransfer.setData('text/song-id', song.id); - console.debug('[Reorder] drag start', { id: song.id, index }); // Explicitly set effect to move for better UX try { e.dataTransfer.effectAllowed = 'move'; } catch {} try { e.dataTransfer.dropEffect = 'move'; } catch {} @@ -549,10 +537,8 @@ export const PaginatedSongList: React.FC = memo(({ if (!fromId && !multiIds) return; // Move to end: omit toId if (multiIds && multiIds.length > 0) { - console.debug('[Reorder] move many to end request', { playlist: currentPlaylist, fromIds: multiIds }); await api.moveTracksInPlaylist(currentPlaylist, multiIds); } else { - console.debug('[Reorder] move to end request', { playlist: currentPlaylist, fromId }); await api.moveTrackInPlaylist(currentPlaylist, fromId!); } await onReorder(songs.map(s => s.id));