From 0f686a301c52428c5d9a690e2cd6da641faa5dc9 Mon Sep 17 00:00:00 2001 From: Finomosec <1665799+Finomosec@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:29:27 +0200 Subject: [PATCH] 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) --- ui/src/album/AlbumActions.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/src/album/AlbumActions.jsx b/ui/src/album/AlbumActions.jsx index 507b43a7e..bd782b25c 100644 --- a/ui/src/album/AlbumActions.jsx +++ b/ui/src/album/AlbumActions.jsx @@ -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 })) }