fix(playlists): markModified on children/tracks to persist order; API response confirms update
This commit is contained in:
parent
5a21243f5b
commit
5a396d774e
@ -112,6 +112,9 @@ router.post('/reorder', async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
for (const p of playlists) {
|
for (const p of playlists) {
|
||||||
reorderNode(p as any);
|
reorderNode(p as any);
|
||||||
|
// Force Mongoose to see deep changes under Mixed children
|
||||||
|
p.markModified('children');
|
||||||
|
p.markModified('tracks');
|
||||||
await p.save();
|
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` });
|
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) {
|
} catch (error) {
|
||||||
console.error('Error reordering playlist:', error);
|
console.error('Error reordering playlist:', error);
|
||||||
res.status(500).json({ error: 'Failed to reorder playlist' });
|
res.status(500).json({ error: 'Failed to reorder playlist' });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user