fix(playlists): markModified on children/tracks to persist order; API response confirms update

This commit is contained in:
Geert Rademakes 2025-08-08 14:20:48 +02:00
parent 5a21243f5b
commit 5a396d774e

View File

@ -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' });