From 70f536e04df0e7603a68ce1a9f7bb60c35873e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deluan=20Quint=C3=A3o?= Date: Tue, 11 Mar 2025 20:19:46 -0400 Subject: [PATCH] fix(ui): skip missing files in bulk operations (#3807) * fix(ui): skip missing files when adding to playqueue Signed-off-by: Deluan * fix(ui): skip missing files when adding to playlists * fix(ui): skip missing files when shuffling songs Signed-off-by: Deluan --------- Signed-off-by: Deluan --- ui/src/actions/player.js | 15 +++++++++++---- ui/src/album/AlbumActions.jsx | 5 +++-- ui/src/common/ContextMenus.jsx | 3 ++- ui/src/common/ShuffleAllButton.jsx | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ui/src/actions/player.js b/ui/src/actions/player.js index a9e2577f4..acef2e9b2 100644 --- a/ui/src/actions/player.js +++ b/ui/src/actions/player.js @@ -14,10 +14,17 @@ export const setTrack = (data) => ({ }) export const filterSongs = (data, ids) => { - if (!ids) { - return data - } - return ids.reduce((acc, id) => ({ ...acc, [id]: data[id] }), {}) + const filteredData = Object.fromEntries( + Object.entries(data).filter(([_, song]) => !song.missing), + ) + return !ids + ? filteredData + : ids.reduce((acc, id) => { + if (filteredData[id]) { + return { ...acc, [id]: filteredData[id] } + } + return acc + }, {}) } export const addTracks = (data, ids) => { diff --git a/ui/src/album/AlbumActions.jsx b/ui/src/album/AlbumActions.jsx index 65d6fe64c..96cfab09a 100644 --- a/ui/src/album/AlbumActions.jsx +++ b/ui/src/album/AlbumActions.jsx @@ -73,8 +73,9 @@ const AlbumActions = ({ }, [dispatch, data, ids]) const handleAddToPlaylist = React.useCallback(() => { - dispatch(openAddToPlaylist({ selectedIds: ids })) - }, [dispatch, ids]) + const selectedIds = ids.filter((id) => !data[id].missing) + dispatch(openAddToPlaylist({ selectedIds })) + }, [dispatch, data, ids]) const handleShare = React.useCallback(() => { dispatch(openShareMenu([record.id], 'album', record.name)) diff --git a/ui/src/common/ContextMenus.jsx b/ui/src/common/ContextMenus.jsx index 623b01a24..855825496 100644 --- a/ui/src/common/ContextMenus.jsx +++ b/ui/src/common/ContextMenus.jsx @@ -233,6 +233,7 @@ export const AlbumContextMenu = (props) => album_id: props.record.id, release_date: props.releaseDate, disc_number: props.discNumber, + missing: false, }, }} /> @@ -262,7 +263,7 @@ export const ArtistContextMenu = (props) => field: 'album', order: 'ASC', }, - filter: { album_artist_id: props.record.id }, + filter: { album_artist_id: props.record.id, missing: false }, }} /> ) : null diff --git a/ui/src/common/ShuffleAllButton.jsx b/ui/src/common/ShuffleAllButton.jsx index bc455b615..1631e2cf5 100644 --- a/ui/src/common/ShuffleAllButton.jsx +++ b/ui/src/common/ShuffleAllButton.jsx @@ -10,6 +10,7 @@ export const ShuffleAllButton = ({ filters }) => { const dataProvider = useDataProvider() const dispatch = useDispatch() const notify = useNotify() + filters = { ...filters, missing: false } const handleOnClick = () => { dataProvider