mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-12-27 07:34:12 +08:00
fix(connections): ws error when switch end point
This commit is contained in:
parent
15d20cde4a
commit
b04b20f8f0
@ -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<void>((resolve) => {
|
||||
export let connections: Accessor<WsMsg> = () => ({
|
||||
uploadTotal: 0,
|
||||
downloadTotal: 0,
|
||||
connections: [],
|
||||
})
|
||||
|
||||
createEffect(() => {
|
||||
if (selectedEndpoint()) {
|
||||
resolve()
|
||||
connections = useWsRequest<WsMsg>('connections')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return useWsRequest<WsMsg>('connections')
|
||||
})
|
||||
|
||||
export const connections = createMemo(() => latestConnectionWsMessage()?.())
|
||||
|
||||
export const useConnections = () => {
|
||||
const [closedConnectionsWithSpeed, setClosedConnectionsWithSpeed] =
|
||||
|
Loading…
x
Reference in New Issue
Block a user