fix: change player.add(...) behavior

This commit is contained in:
Hellyson Rodrigo Parteka 2021-11-17 20:17:08 -03:00 committed by Max Isom
parent 5cc74a3d51
commit 46701a8aab
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880

View file

@ -241,25 +241,12 @@ export default class {
}
add(song: QueuedSong, {immediate = false} = {}): void {
if (song.playlist) {
if (song.playlist || !immediate) {
// Add to end of queue
this.queue.push(song);
} else {
// Not from playlist, add immediately
let insertAt = this.queuePosition + 1;
if (!immediate) {
// Loop until playlist song
this.queue.some(song => {
if (song.playlist) {
return true;
}
insertAt++;
return false;
});
}
// Add as the next song to be played
const insertAt = this.queuePosition + 1;
this.queue = [...this.queue.slice(0, insertAt), song, ...this.queue.slice(insertAt)];
}
}