chore(reorder-debug): add server/client logs for move and playlist order slice to diagnose ordering issue
This commit is contained in:
parent
484d191201
commit
e2d6d55433
@ -154,6 +154,8 @@ 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));
|
||||
node.order = without; // store full order overlay
|
||||
updated = true;
|
||||
return node;
|
||||
|
||||
@ -126,7 +126,8 @@ router.get('/playlist/*', async (req: Request, res: Response) => {
|
||||
};
|
||||
|
||||
const trackIds = getAllTrackIds(playlist);
|
||||
console.log(`Found ${trackIds.length} tracks in playlist "${playlistName}"`);
|
||||
console.log(`[PLAYLIST_ORDER] ${playlistName} tracks count:`, trackIds.length);
|
||||
console.log('[PLAYLIST_ORDER] first 10 ids:', trackIds.slice(0, 10));
|
||||
|
||||
if (trackIds.length === 0) {
|
||||
return res.json({
|
||||
@ -177,6 +178,7 @@ 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();
|
||||
|
||||
@ -299,6 +299,7 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
|
||||
}
|
||||
const toId = songs[index].id;
|
||||
// Simpler and more robust: instruct backend to move fromId before toId
|
||||
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
|
||||
setDragHoverIndex(null);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user