fix(ui): skip missing files in bulk operations (#3807)

* fix(ui): skip missing files when adding to playqueue

Signed-off-by: Deluan <deluan@navidrome.org>

* fix(ui): skip missing files when adding to playlists

* fix(ui): skip missing files when shuffling songs

Signed-off-by: Deluan <deluan@navidrome.org>

---------

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan Quintão 2025-03-11 20:19:46 -04:00 committed by GitHub
parent 2a15a217de
commit 70f536e04d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 7 deletions

View file

@ -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) => {

View file

@ -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))

View file

@ -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

View file

@ -10,6 +10,7 @@ export const ShuffleAllButton = ({ filters }) => {
const dataProvider = useDataProvider()
const dispatch = useDispatch()
const notify = useNotify()
filters = { ...filters, missing: false }
const handleOnClick = () => {
dataProvider