transmission: floor progress percentages instead of rounding

99.97% printed as "100.0%" beside a still-blue bar, which reads as a stuck
torrent. only a genuinely complete fraction shows a hundred now, as "100%".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 17:31:31 +00:00
co-authored by Claude Opus 5
parent ce5bac3cf5
commit 5995cd3ab7
@@ -61,9 +61,15 @@ export function formatDate(unixSeconds: number | undefined | null): string {
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`; return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
} }
/**
* Progress, floored — never rounded. `toFixed` rounds, so 99.97% printed as "100.0%" next to a bar that
* is still blue, which reads as a stuck torrent rather than a nearly-finished one. Only an actually
* complete fraction may show a hundred, and it shows it as a flat "100%" so the two can't be confused.
*/
export function formatPercent(fraction: number | undefined | null): string { export function formatPercent(fraction: number | undefined | null): string {
if (fraction == null) return '—'; if (fraction == null) return '—';
return `${(fraction * 100).toFixed(1)}%`; if (fraction >= 1) return '100%';
return `${(Math.floor(fraction * 1000) / 10).toFixed(1)}%`;
} }
// ── Status ──────────────────────────────────────────────────────────────────────────────────────── // ── Status ────────────────────────────────────────────────────────────────────────────────────────