diff options
Diffstat (limited to 'backend.js')
-rw-r--r-- | backend.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/backend.js b/backend.js index 0ddd15b..57910e9 100644 --- a/backend.js +++ b/backend.js @@ -316,6 +316,37 @@ class Backend extends EventEmitter { return focusItem } + clearQueuePast(track) { + const { items } = this.queueGrouplike + const index = items.indexOf(track) + 1 + + if (index < 0) { + return + } else if (index < items.indexOf(this.playingTrack)) { + items.splice(index, items.length - index, this.playingTrack) + } else { + items.splice(index) + } + + this.emitQueueUpdated() + } + + clearQueueUpTo(track) { + const { items } = this.queueGrouplike + const endIndex = items.indexOf(track) + const startIndex = (this.playingTrack ? items.indexOf(this.playingTrack) + 1 : 0) + + if (endIndex < 0) { + return + } else if (endIndex < startIndex) { + return + } else { + items.splice(startIndex, endIndex - startIndex) + } + + this.emitQueueUpdated() + } + playSooner(item) { this.distributeQueue(item, { how: 'randomly', |