diff options
author | Florrie <towerofnix@gmail.com> | 2019-09-10 12:23:41 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-09-10 12:23:41 -0300 |
commit | 47bd859d1a02683395bbf941d7dc0375d7ef8334 (patch) | |
tree | 484c6fdc82af9b14a2ff1e6894d2ad3b060aa3c6 /backend.js | |
parent | 366b6e90f1d237a8e1e0d92224f65990157d0cd6 (diff) |
'Clear past / up to this track' queue menu 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', |