From bed4be6742cef26df8424eabdae412d7bebc6128 Mon Sep 17 00:00:00 2001 From: Zephyruso <127948745+Zephyruso@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:35:06 +0800 Subject: [PATCH] refactor(proxies): remove allconnections reactive for better performance --- src/signals/connections.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/signals/connections.ts b/src/signals/connections.ts index 8e51a24..ad22e14 100644 --- a/src/signals/connections.ts +++ b/src/signals/connections.ts @@ -12,7 +12,10 @@ type WsMsg = { // we make connections global, so we can keep track of connections when user in proxy page // when user selects proxy and close some connections they can back and check connections // they closed -const [allConnections, setAllConnections] = createSignal([]) +let allConnections: Connection[] = [] +const setAllConnections = (allConns: Connection[]) => { + allConnections = allConns +} export let latestConnectionMsg: Accessor = () => ({ uploadTotal: 0, @@ -96,7 +99,7 @@ export function restructRawMsgToConnection( } export function mergeAllConnections(activeConns: Connection[]) { - return unionWith(allConnections(), activeConns, (a, b) => a.id === b.id) + return unionWith(allConnections, activeConns, (a, b) => a.id === b.id) } function diffClosedConnections(