mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-10 20:32:27 +03:00
Use refetch
when changing the playlist (as opposed to a full refresh
)
This commit is contained in:
parent
85d48478e8
commit
cca32360db
@ -4,7 +4,6 @@ import {
|
|||||||
ListToolbar,
|
ListToolbar,
|
||||||
TextField,
|
TextField,
|
||||||
NumberField,
|
NumberField,
|
||||||
useRefresh,
|
|
||||||
useDataProvider,
|
useDataProvider,
|
||||||
useNotify,
|
useNotify,
|
||||||
useVersion,
|
useVersion,
|
||||||
@ -85,12 +84,11 @@ const ReorderableList = ({ readOnly, children, ...rest }) => {
|
|||||||
|
|
||||||
const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
|
const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
|
||||||
const listContext = useListContext()
|
const listContext = useListContext()
|
||||||
const { data, ids, onUnselectItems } = listContext
|
const { data, ids, selectedIds, onUnselectItems, refetch } = listContext
|
||||||
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
|
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
|
||||||
const classes = useStyles({ isDesktop })
|
const classes = useStyles({ isDesktop })
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const dataProvider = useDataProvider()
|
const dataProvider = useDataProvider()
|
||||||
const refresh = useRefresh()
|
|
||||||
const notify = useNotify()
|
const notify = useNotify()
|
||||||
const version = useVersion()
|
const version = useVersion()
|
||||||
useResourceRefresh('song', 'playlist')
|
useResourceRefresh('song', 'playlist')
|
||||||
@ -98,10 +96,10 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
|
|||||||
const onAddToPlaylist = useCallback(
|
const onAddToPlaylist = useCallback(
|
||||||
(pls) => {
|
(pls) => {
|
||||||
if (pls.id === playlistId) {
|
if (pls.id === playlistId) {
|
||||||
refresh()
|
refetch()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[playlistId, refresh]
|
[playlistId, refetch]
|
||||||
)
|
)
|
||||||
|
|
||||||
const reorder = useCallback(
|
const reorder = useCallback(
|
||||||
@ -113,13 +111,13 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
|
|||||||
filter: { playlist_id: playlistId },
|
filter: { playlist_id: playlistId },
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
refresh()
|
refetch()
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
notify('ra.page.error', 'warning')
|
notify('ra.page.error', 'warning')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[dataProvider, notify, refresh]
|
[dataProvider, notify, refetch]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleDragEnd = useCallback(
|
const handleDragEnd = useCallback(
|
||||||
@ -169,16 +167,15 @@ const PlaylistSongs = ({ playlistId, readOnly, actions, ...props }) => {
|
|||||||
classes={{ toolbar: classes.toolbar }}
|
classes={{ toolbar: classes.toolbar }}
|
||||||
filters={props.filters}
|
filters={props.filters}
|
||||||
actions={actions}
|
actions={actions}
|
||||||
{...listContext}
|
|
||||||
/>
|
/>
|
||||||
<div className={classes.main}>
|
<div className={classes.main}>
|
||||||
<Card
|
<Card
|
||||||
className={clsx(classes.content, {
|
className={clsx(classes.content, {
|
||||||
[classes.bulkActionsDisplayed]: listContext.selectedIds.length > 0,
|
[classes.bulkActionsDisplayed]: selectedIds.length > 0,
|
||||||
})}
|
})}
|
||||||
key={version}
|
key={version}
|
||||||
>
|
>
|
||||||
<BulkActionsToolbar {...listContext}>
|
<BulkActionsToolbar>
|
||||||
<PlaylistSongBulkActions
|
<PlaylistSongBulkActions
|
||||||
playlistId={playlistId}
|
playlistId={playlistId}
|
||||||
onUnselectItems={onUnselectItems}
|
onUnselectItems={onUnselectItems}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user