mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-08 10:27:08 +02:00
fix: pass ordered song IDs to player actions and guard against undefined ids
- Pass allIds to dispatched actions so player knows track order - Check ids is defined before comparing length to prevent crash during initial load when both ids and record.songCount are undefined Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
edf5879523
commit
0f686a301c
1 changed files with 4 additions and 3 deletions
|
|
@ -62,7 +62,7 @@ const AlbumActions = ({
|
|||
|
||||
const getAllSongsAndDispatch = React.useCallback(
|
||||
(action) => {
|
||||
if (ids?.length === record.songCount) {
|
||||
if (ids && ids.length === record.songCount) {
|
||||
return dispatch(action(data, ids))
|
||||
}
|
||||
dataProvider
|
||||
|
|
@ -76,7 +76,8 @@ const AlbumActions = ({
|
|||
(acc, curr) => ({ ...acc, [curr.id]: curr }),
|
||||
{},
|
||||
)
|
||||
dispatch(action(allData))
|
||||
const allIds = res.data.map((s) => s.id)
|
||||
dispatch(action(allData, allIds))
|
||||
})
|
||||
.catch(() => {
|
||||
notify('ra.page.error', 'warning')
|
||||
|
|
@ -102,7 +103,7 @@ const AlbumActions = ({
|
|||
}, [getAllSongsAndDispatch])
|
||||
|
||||
const handleAddToPlaylist = React.useCallback(() => {
|
||||
if (ids?.length === record.songCount) {
|
||||
if (ids && ids.length === record.songCount) {
|
||||
const selectedIds = ids.filter((id) => !data[id].missing)
|
||||
return dispatch(openAddToPlaylist({ selectedIds }))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue