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); this.queue.splice(insertIdx, 0, targetTrack);
if (this.isShuffled) { if (this.isShuffled) {
// Regenerate shuffle indices to be safe as queue shifted // Shift indices that are >= insertIdx because we inserted a new item
this.reshuffle(); this.shuffledIndices = this.shuffledIndices.map((i) =>
// Attempt to place new track next in shuffle order? i >= insertIdx ? i + 1 : i,
// 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.
const newIdx = insertIdx; const newIdx = insertIdx;
// Find where current is in shuffledIndices // Find where current is in shuffledIndices