mirror of
https://github.com/navidrome/navidrome.git
synced 2026-07-02 07:12:36 +00: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
@ -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…
x
Reference in New Issue
Block a user