Fix drag-n-drop from a playlist, also fix useDrag memoization
This commit is contained in:
@@ -103,11 +103,14 @@ const Cover = withContentRect('bounds')(
|
|||||||
// Force height to be the same as the width determined by the GridList
|
// Force height to be the same as the width determined by the GridList
|
||||||
// noinspection JSSuspiciousNameCombination
|
// noinspection JSSuspiciousNameCombination
|
||||||
const classes = useCoverStyles({ height: contentRect.bounds.width })
|
const classes = useCoverStyles({ height: contentRect.bounds.width })
|
||||||
const [, dragAlbumRef] = useDrag(() => ({
|
const [, dragAlbumRef] = useDrag(
|
||||||
|
() => ({
|
||||||
type: DraggableTypes.ALBUM,
|
type: DraggableTypes.ALBUM,
|
||||||
item: { albumIds: [record.id] },
|
item: { albumIds: [record.id] },
|
||||||
options: { dropEffect: 'copy' },
|
options: { dropEffect: 'copy' },
|
||||||
}))
|
}),
|
||||||
|
[record]
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<div ref={measureRef}>
|
<div ref={measureRef}>
|
||||||
<div ref={dragAlbumRef}>
|
<div ref={dragAlbumRef}>
|
||||||
|
|||||||
@@ -51,11 +51,14 @@ const useStyles = makeStyles({
|
|||||||
|
|
||||||
const AlbumDatagridRow = (props) => {
|
const AlbumDatagridRow = (props) => {
|
||||||
const { record } = props
|
const { record } = props
|
||||||
const [, dragAlbumRef] = useDrag(() => ({
|
const [, dragAlbumRef] = useDrag(
|
||||||
|
() => ({
|
||||||
type: DraggableTypes.ALBUM,
|
type: DraggableTypes.ALBUM,
|
||||||
item: { albumIds: [record.id] },
|
item: { albumIds: [record.id] },
|
||||||
options: { dropEffect: 'copy' },
|
options: { dropEffect: 'copy' },
|
||||||
}))
|
}),
|
||||||
|
[record]
|
||||||
|
)
|
||||||
return <DatagridRow ref={dragAlbumRef} {...props} />
|
return <DatagridRow ref={dragAlbumRef} {...props} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,11 +84,14 @@ const ArtistFilter = (props) => {
|
|||||||
|
|
||||||
const ArtistDatagridRow = (props) => {
|
const ArtistDatagridRow = (props) => {
|
||||||
const { record } = props
|
const { record } = props
|
||||||
const [, dragArtistRef] = useDrag(() => ({
|
const [, dragArtistRef] = useDrag(
|
||||||
|
() => ({
|
||||||
type: DraggableTypes.ARTIST,
|
type: DraggableTypes.ARTIST,
|
||||||
item: { artistIds: [record?.id] },
|
item: { artistIds: [record?.id] },
|
||||||
options: { dropEffect: 'copy' },
|
options: { dropEffect: 'copy' },
|
||||||
}))
|
}),
|
||||||
|
[record]
|
||||||
|
)
|
||||||
return <DatagridRow ref={dragArtistRef} {...props} />
|
return <DatagridRow ref={dragArtistRef} {...props} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,19 +106,25 @@ export const SongDatagridRow = ({
|
|||||||
isValidElement(c)
|
isValidElement(c)
|
||||||
)
|
)
|
||||||
|
|
||||||
const [, dragDiscRef] = useDrag(() => ({
|
const [, dragDiscRef] = useDrag(
|
||||||
|
() => ({
|
||||||
type: DraggableTypes.DISC,
|
type: DraggableTypes.DISC,
|
||||||
item: {
|
item: {
|
||||||
discs: [{ albumId: record?.albumId, discNumber: record?.discNumber }],
|
discs: [{ albumId: record?.albumId, discNumber: record?.discNumber }],
|
||||||
},
|
},
|
||||||
options: { dropEffect: 'copy' },
|
options: { dropEffect: 'copy' },
|
||||||
}))
|
}),
|
||||||
|
[record]
|
||||||
|
)
|
||||||
|
|
||||||
const [, dragSongRef] = useDrag(() => ({
|
const [, dragSongRef] = useDrag(
|
||||||
|
() => ({
|
||||||
type: DraggableTypes.SONG,
|
type: DraggableTypes.SONG,
|
||||||
item: { ids: [record?.id] },
|
item: { ids: [record?.mediaFileId || record?.id] },
|
||||||
options: { dropEffect: 'copy' },
|
options: { dropEffect: 'copy' },
|
||||||
}))
|
}),
|
||||||
|
[record]
|
||||||
|
)
|
||||||
|
|
||||||
if (!record || !record.title) {
|
if (!record || !record.title) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
Reference in New Issue
Block a user