diff --git a/renderer/views/torrent-list.js b/renderer/views/torrent-list.js
index 6b6d68ac..c3bcd5fc 100644
--- a/renderer/views/torrent-list.js
+++ b/renderer/views/torrent-list.js
@@ -70,6 +70,7 @@ function TorrentList (state) {
${renderPeers()}
${renderDownloadSpeed()}
${renderUploadSpeed()}
+ ${renderEta()}
`)
}
@@ -106,6 +107,27 @@ function TorrentList (state) {
if (prog.uploadSpeed === 0) return
return hx`↑ ${prettyBytes(prog.uploadSpeed)}/s`
}
+
+ function renderEta () {
+ var downloaded = prog.downloaded
+ var total = prog.length || 0
+ var missing = total - downloaded
+ var downloadSpeed = prog.downloadSpeed
+ if (downloadSpeed === 0 || missing === 0) return
+
+ var rawEta = missing / downloadSpeed
+ var hours = Math.floor(rawEta / 3600) % 24
+ var minutes = Math.floor(rawEta / 60) % 60
+ var seconds = Math.floor(rawEta % 60)
+
+ // Only display hours and minutes if they are greater than 0 but always
+ // display minutes if hours is being displayed
+ var hoursStr = hours ? hours + 'h' : ''
+ var minutesStr = (hours || minutes) ? minutes + 'm' : ''
+ var secondsStr = seconds + 's'
+
+ return hx`ETA: ${hoursStr} ${minutesStr} ${secondsStr}`
+ }
}
// Download button toggles between torrenting (DL/seed) and paused