diff options
| author | 2026-01-14 14:13:50 +0800 | |
|---|---|---|
| committer | 2026-01-14 14:13:50 +0800 | |
| commit | d2b2171d0af3b4b0f59360be7c4c79951458242f (patch) | |
| tree | 248140c85eb668a412620e8642dc0ef92ec7fbae /ui/src | |
| parent | 0b262ee13a9028cc581d1412bcbb729eb7c707f5 (diff) | |
| download | DropOut-d2b2171d0af3b4b0f59360be7c4c79951458242f.tar.gz DropOut-d2b2171d0af3b4b0f59360be7c4c79951458242f.zip | |
Update ui/src/lib/DownloadMonitor.svelte
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Diffstat (limited to 'ui/src')
| -rw-r--r-- | ui/src/lib/DownloadMonitor.svelte | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/ui/src/lib/DownloadMonitor.svelte b/ui/src/lib/DownloadMonitor.svelte index 9adef67..52c935c 100644 --- a/ui/src/lib/DownloadMonitor.svelte +++ b/ui/src/lib/DownloadMonitor.svelte @@ -83,19 +83,12 @@ const timeDiff = (now - lastUpdateTime) / 1000; // seconds if (timeDiff >= 0.5) { // Update speed every 0.5 seconds - // On the first update, initialize lastTotalBytes to avoid counting - // bytes downloaded before the timer window started. - if (lastTotalBytes === 0 && totalDownloadedBytes > 0) { - lastTotalBytes = totalDownloadedBytes; - lastUpdateTime = now; - } else { - const bytesDiff = totalDownloadedBytes - lastTotalBytes; - const instantSpeed = bytesDiff / timeDiff; - // Smooth the speed with exponential moving average - downloadSpeed = downloadSpeed === 0 ? instantSpeed : downloadSpeed * 0.7 + instantSpeed * 0.3; - lastUpdateTime = now; - lastTotalBytes = totalDownloadedBytes; - } + const bytesDiff = totalDownloadedBytes - lastTotalBytes; + const instantSpeed = bytesDiff / timeDiff; + // Smooth the speed with exponential moving average + downloadSpeed = downloadSpeed === 0 ? instantSpeed : downloadSpeed * 0.7 + instantSpeed * 0.3; + lastUpdateTime = now; + lastTotalBytes = totalDownloadedBytes; } // Estimate remaining time |