From 5a396d774e30fb063483582abbf8ae0aa7db84f0 Mon Sep 17 00:00:00 2001 From: Geert Rademakes Date: Fri, 8 Aug 2025 14:20:48 +0200 Subject: [PATCH] fix(playlists): markModified on children/tracks to persist order; API response confirms update --- packages/backend/src/routes/playlists.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/routes/playlists.ts b/packages/backend/src/routes/playlists.ts index 9ab4430..5450c1a 100644 --- a/packages/backend/src/routes/playlists.ts +++ b/packages/backend/src/routes/playlists.ts @@ -112,6 +112,9 @@ router.post('/reorder', async (req: Request, res: Response) => { for (const p of playlists) { reorderNode(p as any); + // Force Mongoose to see deep changes under Mixed children + p.markModified('children'); + p.markModified('tracks'); await p.save(); } @@ -119,7 +122,7 @@ router.post('/reorder', async (req: Request, res: Response) => { return res.status(404).json({ message: `Playlist "${playlistName}" not found` }); } - res.json({ message: 'Playlist order updated' }); + res.json({ message: 'Playlist order updated', playlistName, newLength: orderedIds.length }); } catch (error) { console.error('Error reordering playlist:', error); res.status(500).json({ error: 'Failed to reorder playlist' });