fix(ui): prevent autoplay when clearing the play queue (#5430)

When clearing the queue, the reducer resets to initialState which lacks
an autoPlay field (undefined). The autoPlay option was computed as true
because undefined !== false, causing the music player library to attempt
playback of the first song before internal state was fully cleared.

Added a queue.length > 0 guard to the autoPlay calculation so it is
never true when the queue is empty, regardless of other state flags.

Fixes #5331
This commit is contained in:
Deluan Quintão 2026-04-27 21:45:13 -04:00 committed by GitHub
parent a4c1fa6378
commit d5ba61adf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -210,6 +210,7 @@ const Player = () => {
audioLists: playerState.queue.map((item) => item),
playIndex: playerState.playIndex,
autoPlay:
playerState.queue.length > 0 &&
playerState.autoPlay !== false &&
(playerState.clear || playerState.playIndex === 0),
clearPriorAudioLists: playerState.clear,