diff --git a/src/App.tsx b/src/App.tsx index 73652a0..4e7999d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,12 +4,16 @@ import { twMerge } from 'tailwind-merge' import { Header } from '~/components' import { ROUTES } from '~/constants' import { + WsMsg, curTheme, endpoint, selectedEndpoint, + setAllConnections, + setLatestConnectionMsg, useAutoSwitchTheme, useProxies, useTwemoji, + useWsRequest, } from '~/signals' const Setup = lazy(() => import('~/pages/Setup')) @@ -28,6 +32,8 @@ export const App = () => { createEffect(() => { if (selectedEndpoint() && endpoint()) { void useProxies().updateProxies() + setAllConnections([]) + setLatestConnectionMsg(useWsRequest('connections')) } }) diff --git a/src/signals/connections.ts b/src/signals/connections.ts index 4b70919..272edcd 100644 --- a/src/signals/connections.ts +++ b/src/signals/connections.ts @@ -1,9 +1,8 @@ import { differenceWith, isNumber, unionWith } from 'lodash' import { Accessor, createEffect, createSignal, untrack } from 'solid-js' import { Connection, ConnectionRawMessage } from '~/types' -import { selectedEndpoint, useWsRequest } from './request' -type WsMsg = { +export type WsMsg = { connections: ConnectionRawMessage[] uploadTotal: number downloadTotal: number @@ -13,7 +12,8 @@ type WsMsg = { // when user selects proxy and close some connections they can back and check connections // they closed let allConnections: Connection[] = [] -const setAllConnections = (allConns: Connection[]) => { + +export const setAllConnections = (allConns: Connection[]) => { allConnections = allConns } @@ -23,12 +23,9 @@ export let latestConnectionMsg: Accessor = () => ({ connections: [], }) -createEffect(() => { - if (selectedEndpoint()) { - setAllConnections([]) - latestConnectionMsg = useWsRequest('connections') - } -}) +export const setLatestConnectionMsg = (accessor: Accessor) => { + latestConnectionMsg = accessor +} export const useConnections = () => { const [closedConnections, setClosedConnections] = createSignal(