From bb1dbfcfc3849678f396a2343e85fa0200cb7666 Mon Sep 17 00:00:00 2001 From: wonfen Date: Wed, 19 Feb 2025 02:24:21 +0800 Subject: [PATCH] fix: connections page traffic calculation --- src/locales/en.json | 2 +- src/pages/connections.tsx | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index b29450a6..dc599624 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -178,7 +178,7 @@ "Process": "Process", "Time": "Time", "Source": "Source", - "Destination": "Destination IP", + "Destination": "Destination", "DestinationPort": "Destination Port", "Close Connection": "Close Connection", "Rules": "Rules", diff --git a/src/pages/connections.tsx b/src/pages/connections.tsx index a827b389..dc7f63ef 100644 --- a/src/pages/connections.tsx +++ b/src/pages/connections.tsx @@ -127,9 +127,8 @@ const ConnectionsPage = () => { return isPaused ? (frozenData ?? connData) : connData; }, [isPaused, frozenData, connData]); - const [filterConn, download, upload] = useMemo(() => { + const [filterConn] = useMemo(() => { const orderFunc = orderOpts[curOrderOpt]; - let connections = displayData.connections.filter((conn) => { const { host, destinationIP, process } = conn.metadata; return ( @@ -139,13 +138,7 @@ const ConnectionsPage = () => { if (orderFunc) connections = orderFunc(connections); - let download = 0; - let upload = 0; - connections.forEach((x) => { - download += x.download; - upload += x.upload; - }); - return [connections, download, upload]; + return [connections]; }, [displayData, match, curOrderOpt]); const onCloseAll = useLockFn(closeAllConnections); @@ -181,10 +174,10 @@ const ConnectionsPage = () => { header={ - {t("Downloaded")}: {parseTraffic(download)} + {t("Downloaded")}: {parseTraffic(displayData.downloadTotal)} - {t("Uploaded")}: {parseTraffic(upload)} + {t("Uploaded")}: {parseTraffic(displayData.uploadTotal)}