global player pt. 9 fix play track

This commit is contained in:
2026-02-06 02:11:28 -08:00
parent cedec104a1
commit 0b1a7792b4

View File

@@ -531,6 +531,17 @@ export function insertTrack(track: Track, mode: InsertMode): void {
// Normalize + basic guard // Normalize + basic guard
if (!track || !Number.isFinite(track.id) || !track.src) return; if (!track || !Number.isFinite(track.id) || !track.src) return;
// If the user hits "Play" / "Play next" on the *currently playing* track,
// treat it as a no-op. This avoids trying to move the current track to
// "right after itself" and then skipping, which can produce confusing
// queue changes (and in some cases corrupt traversal state).
//
// NOTE: "Add to queue" still dedupes below, but we early-return there too.
if (currentIndex != null && queue[currentIndex]?.id === track.id) {
queueNotify();
return;
}
// Empty queue behavior // Empty queue behavior
if (queue.length === 0) { if (queue.length === 0) {
queue = [track]; queue = [track];