fix(ui): prevent "Play Next" restarting play at top of queue (#5049)
Set playIndex when rebuilding the queue in reducePlayNext so the music player library knows which track is currently playing. Without this, the library's loadNewAudioLists defaults playIndex to 0, causing playback to restart from the top of the queue on rapid "Play Next" actions. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -127,10 +127,12 @@ const reducePlayNext = (state, { data }) => {
|
|||||||
const newQueue = []
|
const newQueue = []
|
||||||
const current = state.current || {}
|
const current = state.current || {}
|
||||||
let foundPos = false
|
let foundPos = false
|
||||||
|
let currentIndex = 0
|
||||||
state.queue.forEach((item) => {
|
state.queue.forEach((item) => {
|
||||||
newQueue.push(item)
|
newQueue.push(item)
|
||||||
if (item.uuid === current.uuid) {
|
if (item.uuid === current.uuid) {
|
||||||
foundPos = true
|
foundPos = true
|
||||||
|
currentIndex = newQueue.length - 1
|
||||||
Object.keys(data).forEach((id) => {
|
Object.keys(data).forEach((id) => {
|
||||||
newQueue.push(mapToAudioLists(data[id]))
|
newQueue.push(mapToAudioLists(data[id]))
|
||||||
})
|
})
|
||||||
@@ -145,6 +147,7 @@ const reducePlayNext = (state, { data }) => {
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
queue: newQueue,
|
queue: newQueue,
|
||||||
|
playIndex: foundPos ? currentIndex : undefined,
|
||||||
clear: true,
|
clear: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user