fix: AlbumShow was adding previous played tracks when trying to shuffle the album

This commit is contained in:
Deluan 2020-03-02 14:51:52 -05:00
parent 5e7aaa667b
commit 28bc9c1d4f
2 changed files with 10 additions and 3 deletions

View File

@ -21,6 +21,13 @@ export const AlbumActions = ({
const dispatch = useDispatch()
const translate = useTranslate()
// TODO Not sure why data is accumulating tracks from previous plays... Needs investigation. For now, filter out
// the unwanted tracks
const filteredData = ids.reduce((acc, id) => {
acc[id] = data[id]
return acc
}, {})
const shuffle = (data) => {
const ids = Object.keys(data)
for (let i = ids.length - 1; i > 0; i--) {
@ -37,7 +44,7 @@ export const AlbumActions = ({
<Button
color={'secondary'}
onClick={() => {
dispatch(playAlbum(ids[0], data))
dispatch(playAlbum(ids[0], filteredData))
}}
label={translate('resources.album.actions.playAll')}
>
@ -46,7 +53,7 @@ export const AlbumActions = ({
<Button
color={'secondary'}
onClick={() => {
const shuffled = shuffle(data)
const shuffled = shuffle(filteredData)
const firstId = Object.keys(shuffled)[0]
dispatch(playAlbum(firstId, shuffled))
}}

View File

@ -8,7 +8,7 @@ const PLAYER_SCROBBLE = 'PLAYER_SCROBBLE'
const PLAYER_PLAY_ALBUM = 'PLAYER_PLAY_ALBUM'
const mapToAudioLists = (item) => ({
id: item.id,
// id: item.id,
name: item.title,
singer: item.artist,
cover: subsonicUrl('getCoverArt', item.id, { size: 300 }),