better approx
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 21s

This commit is contained in:
Mylloon 2024-11-02 17:29:01 +01:00
parent 5c5d35d5ca
commit ae6e6960e0
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -187,7 +187,18 @@ export default {
return loc.get("c_play_sub2_name");
}
const estimation = timeToString(queue.estimatedDuration);
const estimation = timeToString(
[queue.currentTrack, ...queue.tracks.toArray()]
.filter((t) => t !== null)
.slice(0, pos)
.reduce((total, t) => {
if (total === 0) {
// TODO: First track, already playing, we have to substract the already elapsed time
return t.durationMS;
}
return total + t.durationMS;
}, 0),
);
return `${loc.get("c_play10")} ${pos} (${loc.get("c_play11")}${estimation})`;
};