Fix drag-n-drop from a playlist, also fix useDrag memoization

This commit is contained in:
Deluan
2021-10-23 12:54:17 -04:00
committed by Deluan Quintão
parent 2e2a647e67
commit 31c598de07
4 changed files with 42 additions and 27 deletions
+18 -12
View File
@@ -106,19 +106,25 @@ export const SongDatagridRow = ({
isValidElement(c)
)
const [, dragDiscRef] = useDrag(() => ({
type: DraggableTypes.DISC,
item: {
discs: [{ albumId: record?.albumId, discNumber: record?.discNumber }],
},
options: { dropEffect: 'copy' },
}))
const [, dragDiscRef] = useDrag(
() => ({
type: DraggableTypes.DISC,
item: {
discs: [{ albumId: record?.albumId, discNumber: record?.discNumber }],
},
options: { dropEffect: 'copy' },
}),
[record]
)
const [, dragSongRef] = useDrag(() => ({
type: DraggableTypes.SONG,
item: { ids: [record?.id] },
options: { dropEffect: 'copy' },
}))
const [, dragSongRef] = useDrag(
() => ({
type: DraggableTypes.SONG,
item: { ids: [record?.mediaFileId || record?.id] },
options: { dropEffect: 'copy' },
}),
[record]
)
if (!record || !record.title) {
return null