diff --git a/src/signals/connections.ts b/src/signals/connections.ts index 6b538f2..e3187e8 100644 --- a/src/signals/connections.ts +++ b/src/signals/connections.ts @@ -1,11 +1,5 @@ import { differenceWith, unionWith } from 'lodash' -import { - createEffect, - createMemo, - createResource, - createSignal, - untrack, -} from 'solid-js' +import { Accessor, createEffect, createSignal, untrack } from 'solid-js' import { Connection, ConnectionWithSpeed } from '~/types' import { selectedEndpoint, useWsRequest } from './request' @@ -22,19 +16,17 @@ const [allConnectionsWithSpeed, setAllConnectionsWithSpeed] = createSignal< ConnectionWithSpeed[] >([]) -const [latestConnectionWsMessage] = createResource(async () => { - await new Promise((resolve) => { - createEffect(() => { - if (selectedEndpoint()) { - resolve() - } - }) - }) - - return useWsRequest('connections') +export let connections: Accessor = () => ({ + uploadTotal: 0, + downloadTotal: 0, + connections: [], }) -export const connections = createMemo(() => latestConnectionWsMessage()?.()) +createEffect(() => { + if (selectedEndpoint()) { + connections = useWsRequest('connections') + } +}) export const useConnections = () => { const [closedConnectionsWithSpeed, setClosedConnectionsWithSpeed] =