Skip to content

Commit

Permalink
fix(connections): ws error when switch end point
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso authored and Zephyruso committed Sep 8, 2023
1 parent 15d20cd commit b04b20f
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/signals/connections.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -22,19 +16,17 @@ const [allConnectionsWithSpeed, setAllConnectionsWithSpeed] = createSignal<
ConnectionWithSpeed[]
>([])

const [latestConnectionWsMessage] = createResource(async () => {
await new Promise<void>((resolve) => {
createEffect(() => {
if (selectedEndpoint()) {
resolve()
}
})
})

return useWsRequest<WsMsg>('connections')
export let connections: Accessor<WsMsg> = () => ({
uploadTotal: 0,
downloadTotal: 0,
connections: [],
})

export const connections = createMemo(() => latestConnectionWsMessage()?.())
createEffect(() => {
if (selectedEndpoint()) {
connections = useWsRequest<WsMsg>('connections')
}
})

export const useConnections = () => {
const [closedConnectionsWithSpeed, setClosedConnectionsWithSpeed] =
Expand Down

0 comments on commit b04b20f

Please sign in to comment.