fix(panel-sharing): use adaptive units in formatFlowGB to display small traffic values

This commit is contained in:
sagit
2026-02-11 02:17:38 +00:00
parent aef329149d
commit bdc3513a68
+6 -2
View File
@@ -275,9 +275,13 @@ export default function PanelSharingPage() {
const formatFlowGB = (bytes: number) => {
if (!Number.isFinite(bytes) || bytes <= 0) {
return "0.00 GB";
return "0 B";
}
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
if (bytes < 1024) return bytes + " B";
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + " KB";
if (bytes < 1024 * 1024 * 1024)
return (bytes / (1024 * 1024)).toFixed(2) + " MB";
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + " GB";
};
const formatChainType = (chainType: number, hopInx: number) => {