Show download speed in MB/s instead of Mbps.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jos Vooges | STH 2026-09-08 02:05:33 +02:00
parent f1e927726c
commit e841997399

View file

@ -86,13 +86,15 @@ function targetLabel(t?: string): string {
return TARGET_OPTIONS.find((o) => o.id === t)?.label || t || "4K"; return TARGET_OPTIONS.find((o) => o.id === t)?.label || t || "4K";
} }
function formatMbps(bps: number | null | undefined): string { function formatSpeed(bps: number | null | undefined): string {
if (bps == null || bps < 0) return "—"; if (bps == null || bps < 0) return "—";
if (bps === 0) return "0 Mbps"; if (bps === 0) return "0 MB/s";
const mbps = (bps * 8) / 1_000_000; const mbs = bps / 1_000_000;
if (mbps >= 10) return `${mbps.toFixed(0)} Mbps`; if (mbs >= 10) return `${mbs.toFixed(1)} MB/s`;
if (mbps >= 1) return `${mbps.toFixed(1)} Mbps`; if (mbs >= 1) return `${mbs.toFixed(2)} MB/s`;
return `${(mbps * 1000).toFixed(0)} Kbps`; const kbs = bps / 1000;
if (kbs >= 1) return `${kbs.toFixed(0)} KB/s`;
return `${bps.toFixed(0)} B/s`;
} }
function progressLabel(job: JobRow): string { function progressLabel(job: JobRow): string {
@ -102,7 +104,7 @@ function progressLabel(job: JobRow): string {
if (!p) return "…"; if (!p) return "…";
const parts: string[] = []; const parts: string[] = [];
if (p.percent != null) parts.push(`${p.percent % 1 === 0 ? p.percent.toFixed(0) : p.percent.toFixed(1)}%`); if (p.percent != null) parts.push(`${p.percent % 1 === 0 ? p.percent.toFixed(0) : p.percent.toFixed(1)}%`);
parts.push(formatMbps(p.speedBps)); parts.push(formatSpeed(p.speedBps));
return parts.join(" · "); return parts.join(" · ");
} }