time remaining in progress now seems to work...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-12-22 18:48:00 +03:00
parent 5acd8d2afc
commit 75c78bf72a

View File

@ -170,12 +170,10 @@ var ProgressActions = actions.Actions({
: parseInt(value)) : parseInt(value))
: v) } : v) }
// XXX REMAINING_TIME
var prev = cache.prev || 0 var prev = cache.prev || 0
value = cache.prev = updateValue('value', value) value = cache.prev = updateValue('value', value)
max = updateValue('max', max) max = updateValue('max', max)
// XXX REMAINING_TIME
// estimate time to completion... // estimate time to completion...
var t0 = cache.timestamp || Date.now() var t0 = cache.timestamp || Date.now()
var t = (cache.timestamp = Date.now()) - t0 var t = (cache.timestamp = Date.now()) - t0
@ -186,9 +184,9 @@ var ProgressActions = actions.Actions({
avg > 0 avg > 0
&& remaining.setMilliseconds( && remaining.setMilliseconds(
avg avg
* (max-value) * (max-value)
// make the estimate a bit pessimistic... // make the estimate a bit pessimistic...
* 1.3) * 1.3)
// update not due yet... // update not due yet...
if('timeout' in cache){ if('timeout' in cache){
@ -277,10 +275,10 @@ var ProgressActions = actions.Actions({
timeout timeout
&& clearTimeout(JSON.parse(timeout)) && clearTimeout(JSON.parse(timeout))
//* XXX REMAINING_TIME
// time remaining... // time remaining...
var t = remaining ? // NOTE: we show hours only if > 0...
` t:-${ var t = (remaining && remaining.valueOf()) ?
` / -${
remaining.toISOString() remaining.toISOString()
.substr(11, 8) .substr(11, 8)
.replace(/^00:/, '') }s` .replace(/^00:/, '') }s`