From 9802be29ba650ee338d9601d3614e70ccdc52a45 Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 4 Jun 2019 10:45:12 -0300 Subject: Don't add saved time data duration if not playing I.e. if we aren't playing a track, don't take into account the remaining time of the "current track" saved by the playback info element if we aren't actually playing any track right now. --- ui.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui.js b/ui.js index 6127f0f..d9db800 100644 --- a/ui.js +++ b/ui.js @@ -1110,8 +1110,12 @@ class AppElement extends FocusElement { return acc + (metadata && metadata.duration) || 0 } - const { curSecTotal = 0, lenSecTotal = 0 } = this.playbackInfoElement.timeData - const trackRemainSec = lenSecTotal - curSecTotal + let trackRemainSec = 0 + + if (this.playingTrack) { + const { curSecTotal = 0, lenSecTotal = 0 } = this.playbackInfoElement.timeData + trackRemainSec = lenSecTotal - curSecTotal + } const index = items.indexOf(this.playingTrack) + 1 const aheadRemainSec = items.slice(index).reduce(durationFn, 0) -- cgit 1.3.0-6-gf8a5