refactor(proxies): remove allconnections reactive for better performance

This commit is contained in:
Zephyruso 2023-09-08 15:35:06 +08:00
parent a7213df135
commit bed4be6742

View File

@ -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<Connection[]>([])
let allConnections: Connection[] = []
const setAllConnections = (allConns: Connection[]) => {
allConnections = allConns
}
export let latestConnectionMsg: Accessor<WsMsg> = () => ({
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(