From 17765bdba9dcd6a714f6399feb22505fb7fd79cb Mon Sep 17 00:00:00 2001 From: Sukka Date: Mon, 17 Jun 2024 13:36:35 +0800 Subject: [PATCH] fix(#1226): missing conn unsub (#1228) --- src/pages/connections.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pages/connections.tsx b/src/pages/connections.tsx index d69d3f2..a5c04c5 100644 --- a/src/pages/connections.tsx +++ b/src/pages/connections.tsx @@ -21,7 +21,11 @@ import { BaseStyledSelect } from "@/components/base/base-styled-select"; import useSWRSubscription from "swr/subscription"; import { createSockette } from "@/utils/websocket"; -const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] }; +const initConn: IConnections = { + uploadTotal: 0, + downloadTotal: 0, + connections: [], +}; type OrderFunc = (list: IConnectionsItem[]) => IConnectionsItem[]; @@ -94,9 +98,16 @@ const ConnectionsPage = () => { return { ...data, connections }; }); }, + onerror(event) { + next(event); + }, }, 3 ); + + return () => { + s.close(); + }; }); const [filterConn, download, upload] = useMemo(() => { @@ -106,6 +117,7 @@ const ConnectionsPage = () => { ); if (orderFunc) connections = orderFunc(connections); + let download = 0; let upload = 0; connections.forEach((x) => {