fix(dnd): bubble drop handler through nested folders; add debug log on handler invoke; harden /playlists/batch insertMany
This commit is contained in:
parent
6eabfdedd0
commit
dc11487a9f
@ -69,8 +69,10 @@ router.get('/structure', async (req: Request, res: Response) => {
|
|||||||
// Save playlists in batch (replacing all existing ones)
|
// Save playlists in batch (replacing all existing ones)
|
||||||
router.post('/batch', async (req, res) => {
|
router.post('/batch', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
await Playlist.deleteMany({}); // Clear existing playlists
|
// Replace all playlists atomically
|
||||||
const playlists = await Playlist.create(req.body);
|
await Playlist.deleteMany({});
|
||||||
|
const payload = Array.isArray(req.body) ? req.body : [];
|
||||||
|
const playlists = await Playlist.insertMany(payload, { ordered: false });
|
||||||
res.json(playlists);
|
res.json(playlists);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving playlists:', error);
|
console.error('Error saving playlists:', error);
|
||||||
|
|||||||
@ -250,7 +250,9 @@ const RekordboxReader: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updatedFullTree = applyAdd(fullTree);
|
const updatedFullTree = applyAdd(fullTree);
|
||||||
|
console.debug('[DnD] saving playlists with added tracks', { playlistName, addCount: songIds.length });
|
||||||
await api.savePlaylists(updatedFullTree);
|
await api.savePlaylists(updatedFullTree);
|
||||||
|
console.debug('[DnD] playlists saved');
|
||||||
|
|
||||||
// Reload structure for UI counters
|
// Reload structure for UI counters
|
||||||
const structure = await api.getPlaylistStructure();
|
const structure = await api.getPlaylistStructure();
|
||||||
|
|||||||
@ -208,6 +208,7 @@ const PlaylistItem: React.FC<PlaylistItemProps> = React.memo(({
|
|||||||
onPlaylistDelete={onPlaylistDelete}
|
onPlaylistDelete={onPlaylistDelete}
|
||||||
onPlaylistMove={onPlaylistMove}
|
onPlaylistMove={onPlaylistMove}
|
||||||
allFolders={allFolders}
|
allFolders={allFolders}
|
||||||
|
onDropSongs={onDropSongs}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</VStack>
|
</VStack>
|
||||||
@ -255,6 +256,7 @@ const PlaylistItem: React.FC<PlaylistItemProps> = React.memo(({
|
|||||||
parsed = (window as any).__rbDragPayload;
|
parsed = (window as any).__rbDragPayload;
|
||||||
}
|
}
|
||||||
if (parsed?.type === 'songs' && Array.isArray(parsed.songIds) && onDropSongs) {
|
if (parsed?.type === 'songs' && Array.isArray(parsed.songIds) && onDropSongs) {
|
||||||
|
console.debug('[DnD] invoking onDropSongs', node.name, parsed.songIds.length);
|
||||||
onDropSongs(node.name, parsed.songIds);
|
onDropSongs(node.name, parsed.songIds);
|
||||||
}
|
}
|
||||||
console.debug('[DnD] drop playlist', node.name, parsed, 'raw len', json?.length || 0);
|
console.debug('[DnD] drop playlist', node.name, parsed, 'raw len', json?.length || 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user