From f0e6dd7283b3825d8ded273179ba113924605979 Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 8 Aug 2019 19:36:36 -0300 Subject: Separate remaining duration calculation ...into its own function. To be used to get the total duration string of a grouplike. (This is stored on the backend instead of a more general playlist-utils function because it requires access to the metadata code specific to mtui.) --- ui.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'ui.js') diff --git a/ui.js b/ui.js index bdb5711..fa29fd6 100644 --- a/ui.js +++ b/ui.js @@ -1013,14 +1013,6 @@ class AppElement extends FocusElement { const { playingTrack } = this.backend const { items } = this.backend.queueGrouplike - let noticedMissingMetadata = false - - const durationFn = (acc, track) => { - const metadata = this.backend.getMetadataFor(track) - if (!metadata) noticedMissingMetadata = true - return acc + (metadata && metadata.duration) || 0 - } - let trackRemainSec = 0 if (playingTrack) { @@ -1045,8 +1037,7 @@ class AppElement extends FocusElement { } } - const aheadRemainSec = items.slice(index).reduce(durationFn, 0) - + const { seconds: aheadRemainSec, approxSymbol } = this.backend.getDuration({items: items.slice(index)}) const totalRemainSec = trackRemainSec + aheadRemainSec const { duration } = getTimeStringsFromSec(0, totalRemainSec) @@ -1055,7 +1046,6 @@ class AppElement extends FocusElement { ? `(${this.playSymbol} ${index} / ${items.length})` : `(${items.length})`) - const approxSymbol = noticedMissingMetadata ? '+' : '' this.queueTimeLabel.text = `(${duration + approxSymbol})` this.queueLengthLabel.centerInParent() -- cgit 1.3.0-6-gf8a5