diff options
-rw-r--r-- | backend.js | 31 | ||||
-rw-r--r-- | todo.txt | 13 | ||||
-rw-r--r-- | ui.js | 22 |
3 files changed, 66 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', diff --git a/todo.txt b/todo.txt index 216a488..14c2dd1 100644 --- a/todo.txt +++ b/todo.txt @@ -288,3 +288,16 @@ TODO: When you queue a song which is already before the current song / insert index in the queue, it ends up being placed one index closer to the end than intended. Fix this! (Done!) + +TODO: A "clear after this track" option. Maybe also a corresponding "clear + up to this track" option? + (Done!) + +TODO: Maybe also a "pause after this track" option. Worth considering! + +TODO: Pay closer attention to the ordering of queue items' context menu... + I like how it is right now for accessibility to specific menu items + (play sooner/later immediately under the start position, remove from + queue one "above" the start pos = at the bottom) -- but it might make + more logical sense to group 'play sooner', 'play next', and 'remove + from queue' all into one section. diff --git a/ui.js b/ui.js index 8d13f57..fb73061 100644 --- a/ui.js +++ b/ui.js @@ -565,6 +565,24 @@ class AppElement extends FocusElement { this.queueListingElement.selectAndShow(item) } + clearQueuePast(item) { + if (!this.config.canControlQueue) { + return + } + + this.backend.clearQueuePast(item) + this.queueListingElement.selectAndShow(item) + } + + clearQueueUpTo(item) { + if (!this.config.canControlQueue) { + return + } + + this.backend.clearQueueUpTo(item) + this.queueListingElement.selectAndShow(item) + } + deselectAll() { this.markGrouplike.items.splice(0) } @@ -599,6 +617,10 @@ class AppElement extends FocusElement { {divider: true}, canControlQueue && {label: 'Play later', action: () => this.playLater(item)}, canControlQueue && {label: 'Play sooner', action: () => this.playSooner(item)}, + {divider: true}, + canControlQueue && {label: 'Clear past this track', action: () => this.clearQueuePast(item)}, + canControlQueue && {label: 'Clear up to this track', action: () => this.clearQueueUpTo(item)}, + {divider: true}, canControlQueue && {label: 'Remove from queue', action: () => this.unqueue(item)} ] } else { |