fix: include all active torrent states

This commit is contained in:
Developer
2026-07-14 17:20:27 +00:00
parent 03aece02b8
commit 230b4b8533
6 changed files with 46 additions and 19 deletions
@@ -50,7 +50,9 @@ const UPLOAD_STATES = new Set(["uploading", "forcedUP", "stalledUP"]);
function stateLabel(state: string): string {
return (
STATE_LABELS[state] ??
state.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/^./, (char) => char.toUpperCase())
state
.replace(/([a-z])([A-Z])/g, "$1 $2")
.replace(/^./, (char) => char.toUpperCase())
);
}
@@ -76,7 +78,8 @@ export function QbittorrentTotalsWidget({
payload?.by_direction?.downloading ??
fallbackDirectionCount(byState, DOWNLOAD_STATES);
const uploading =
payload?.by_direction?.uploading ?? fallbackDirectionCount(byState, UPLOAD_STATES);
payload?.by_direction?.uploading ??
fallbackDirectionCount(byState, UPLOAD_STATES);
const stateEntries = Object.entries(byState).sort(
([stateA, countA], [stateB, countB]) =>
countB - countA || stateLabel(stateA).localeCompare(stateLabel(stateB)),
@@ -95,7 +98,9 @@ export function QbittorrentTotalsWidget({
<div className="grid grid-cols-3 gap-2">
<div className="rounded-md border p-3">
<div className="text-2xl font-semibold">{payload.total ?? 0}</div>
<div className="text-xs text-muted-foreground">Total torrents</div>
<div className="text-xs text-muted-foreground">
Total torrents
</div>
</div>
<div className="rounded-md border p-3">
<div className="text-2xl font-semibold">{downloading}</div>
@@ -126,7 +131,9 @@ export function QbittorrentTotalsWidget({
)}
</div>
) : (
<div className="text-xs text-muted-foreground">No torrent data available.</div>
<div className="text-xs text-muted-foreground">
No torrent data available.
</div>
)}
</SectionCard>
);