fix shuffle

This commit is contained in:
2026-02-10 01:28:36 -08:00
parent 57320232a6
commit 99e6fd8eb4

View File

@@ -146,13 +146,11 @@ class PlayerStore {
this.queue.splice(insertIdx, 0, targetTrack);
if (this.isShuffled) {
// Regenerate shuffle indices to be safe as queue shifted
this.reshuffle();
// Attempt to place new track next in shuffle order?
// The reshuffle logic handles "current first", rest random.
// Ideally we want playNext to be deterministic even in shuffle.
// Getting complex. Let's stick to: "Play Next" inserts after current in Queue.
// If Shuffle is on, we force it to be next in shuffledIndices too.
// Shift indices that are >= insertIdx because we inserted a new item
this.shuffledIndices = this.shuffledIndices.map((i) =>
i >= insertIdx ? i + 1 : i,
);
const newIdx = insertIdx;
// Find where current is in shuffledIndices