diff --git a/AppImage/components/system-overview.tsx b/AppImage/components/system-overview.tsx index 98c4266..0a7a7aa 100644 --- a/AppImage/components/system-overview.tsx +++ b/AppImage/components/system-overview.tsx @@ -674,14 +674,18 @@ export function SystemOverview() {
Received: - ↓ {networkData.traffic.bytes_recv.toFixed(2)} {networkUnit === "Bits" ? "Gb" : "GB"} + ↓ {networkUnit === "Bytes" + ? `${networkTotals.received.toFixed(2)} GB` + : `${(networkTotals.received * 8).toFixed(2)} Gb`} ({getTimeframeLabel(networkTimeframe)})
Sent: - ↑ {networkData.traffic.bytes_sent.toFixed(2)} {networkUnit === "Bits" ? "Gb" : "GB"} + ↑ {networkUnit === "Bytes" + ? `${networkTotals.sent.toFixed(2)} GB` + : `${(networkTotals.sent * 8).toFixed(2)} Gb`} ({getTimeframeLabel(networkTimeframe)})
diff --git a/AppImage/components/virtual-machines.tsx b/AppImage/components/virtual-machines.tsx index 7e52a14..07f842c 100644 --- a/AppImage/components/virtual-machines.tsx +++ b/AppImage/components/virtual-machines.tsx @@ -129,7 +129,7 @@ const formatBytes = (bytes: number | undefined, isNetwork: boolean = false): str if (isNetwork) { const networkUnit = getNetworkUnit() - return formatNetworkTraffic(bytes, networkUnit) + return formatNetworkTraffic(bytes, networkUnit, 2) } // For non-network (disk), use standard bytes diff --git a/AppImage/lib/format-network.ts b/AppImage/lib/format-network.ts index 43cca41..b7e137a 100644 --- a/AppImage/lib/format-network.ts +++ b/AppImage/lib/format-network.ts @@ -20,7 +20,7 @@ export function formatNetworkTraffic( if (bytes === 0) return unit === 'Bits' ? '0 b' : '0 B'; const k = unit === 'Bits' ? 1000 : 1024; - const dm = decimals < 0 ? 0 : decimals; + const dm = decimals < 0 ? 0 : Math.min(decimals, 2); // For Bits: convert bytes to bits first (multiply by 8) const value = unit === 'Bits' ? bytes * 8 : bytes; @@ -30,7 +30,8 @@ export function formatNetworkTraffic( : ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; const i = Math.floor(Math.log(value) / Math.log(k)); - const formattedValue = parseFloat((value / Math.pow(k, i)).toFixed(dm)); + const finalDecimals = i >= 3 ? 2 : 2; + const formattedValue = parseFloat((value / Math.pow(k, i)).toFixed(finalDecimals)); return `${formattedValue} ${sizes[i]}`; }