mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-06 21:31:07 +03:00
fix: AlbumShow was adding previous played tracks when trying to shuffle the album
This commit is contained in:
parent
5e7aaa667b
commit
28bc9c1d4f
@ -21,6 +21,13 @@ export const AlbumActions = ({
|
|||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const translate = useTranslate()
|
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 shuffle = (data) => {
|
||||||
const ids = Object.keys(data)
|
const ids = Object.keys(data)
|
||||||
for (let i = ids.length - 1; i > 0; i--) {
|
for (let i = ids.length - 1; i > 0; i--) {
|
||||||
@ -37,7 +44,7 @@ export const AlbumActions = ({
|
|||||||
<Button
|
<Button
|
||||||
color={'secondary'}
|
color={'secondary'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
dispatch(playAlbum(ids[0], data))
|
dispatch(playAlbum(ids[0], filteredData))
|
||||||
}}
|
}}
|
||||||
label={translate('resources.album.actions.playAll')}
|
label={translate('resources.album.actions.playAll')}
|
||||||
>
|
>
|
||||||
@ -46,7 +53,7 @@ export const AlbumActions = ({
|
|||||||
<Button
|
<Button
|
||||||
color={'secondary'}
|
color={'secondary'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const shuffled = shuffle(data)
|
const shuffled = shuffle(filteredData)
|
||||||
const firstId = Object.keys(shuffled)[0]
|
const firstId = Object.keys(shuffled)[0]
|
||||||
dispatch(playAlbum(firstId, shuffled))
|
dispatch(playAlbum(firstId, shuffled))
|
||||||
}}
|
}}
|
||||||
|
@ -8,7 +8,7 @@ const PLAYER_SCROBBLE = 'PLAYER_SCROBBLE'
|
|||||||
const PLAYER_PLAY_ALBUM = 'PLAYER_PLAY_ALBUM'
|
const PLAYER_PLAY_ALBUM = 'PLAYER_PLAY_ALBUM'
|
||||||
|
|
||||||
const mapToAudioLists = (item) => ({
|
const mapToAudioLists = (item) => ({
|
||||||
id: item.id,
|
// id: item.id,
|
||||||
name: item.title,
|
name: item.title,
|
||||||
singer: item.artist,
|
singer: item.artist,
|
||||||
cover: subsonicUrl('getCoverArt', item.id, { size: 300 }),
|
cover: subsonicUrl('getCoverArt', item.id, { size: 300 }),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user