From c30367f90211e6cfa61482bb68f829ee210e5cb6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 17 Jul 2021 21:43:22 -0300 Subject: auto expand/collapse timestamps (for SQP) --- todo.txt | 4 ++++ ui.js | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/todo.txt b/todo.txt index dadbca7..f8202c2 100644 --- a/todo.txt +++ b/todo.txt @@ -598,8 +598,12 @@ TODO: Some kind of timestamp indicator in the progress bar area??? E.g, name TODO: Timestamp editing within mtui itself????????? TODO: Automatically expand/collapse timestamp lists in the queue sidebar! + (Done!) TODO: Apparently, seeking to a timestamp under a previous track in the queue doesn't respect the current queue order (i.e. it sticks the track after the current track). Definitely a bug! (Done - fixed!) + +TODO: Next/previous buttons should seek between timestamps if there are more + within the same track. diff --git a/ui.js b/ui.js index c62f93a..b67fc8d 100644 --- a/ui.js +++ b/ui.js @@ -549,6 +549,18 @@ class AppElement extends FocusElement { } } + // Unfortunately, there isn't really any reliable way to make these work if + // the containing queue isn't of the selected queue player. + const timestampData = track && this.getTimestampData(track) + if (timestampData && queuePlayer === this.SQP) { + this.queueListingElement.expandTimestamps(track) + } + + const oldTimestampData = oldTrack && this.getTimestampData(oldTrack) + if (oldTimestampData && queuePlayer === this.SQP) { + this.queueListingElement.collapseTimestamps(oldTrack) + } + if (track && this.enableAutoDJ) { queuePlayer.setVolumeMultiplier(0.5); const message = 'now playing: ' + getNameWithoutTrackNumber(track); @@ -1943,7 +1955,7 @@ class AppElement extends FocusElement { if (isTimestamp && selectedIndex === playingIndex) { const selectedTimestampIndex = timestampData.indexOf(selectedInput.data) - const found = timestampData.findIndex(ts => ts.timestamp > timeData.curSecTotal) + const found = timestampData.findIndex(ts => ts.timestamp > trackPassedSec) const playingTimestampIndex = (found >= 0 ? found - 1 : 0) const distance = Math.abs(selectedTimestampIndex - playingTimestampIndex) @@ -2232,8 +2244,11 @@ class GrouplikeListingElement extends Form { expandTimestamps(item) { if (this.grouplike && this.grouplike.items.includes(item)) { - this.expandedTimestamps.push(item) - this.buildTimestampItems() + const ET = this.expandedTimestamps + if (!ET.includes(item)) { + this.expandedTimestamps.push(item) + this.buildTimestampItems() + } } } -- cgit 1.3.0-6-gf8a5