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 { differenceWith, unionWith } from 'lodash'
|
||||||
import {
|
import { Accessor, createEffect, createSignal, untrack } from 'solid-js'
|
||||||
createEffect,
|
|
||||||
createMemo,
|
|
||||||
createResource,
|
|
||||||
createSignal,
|
|
||||||
untrack,
|
|
||||||
} from 'solid-js'
|
|
||||||
import { Connection, ConnectionWithSpeed } from '~/types'
|
import { Connection, ConnectionWithSpeed } from '~/types'
|
||||||
import { selectedEndpoint, useWsRequest } from './request'
|
import { selectedEndpoint, useWsRequest } from './request'
|
||||||
|
|
||||||
@ -22,19 +16,17 @@ const [allConnectionsWithSpeed, setAllConnectionsWithSpeed] = createSignal<
|
|||||||
ConnectionWithSpeed[]
|
ConnectionWithSpeed[]
|
||||||
>([])
|
>([])
|
||||||
|
|
||||||
const [latestConnectionWsMessage] = createResource(async () => {
|
export let connections: Accessor<WsMsg> = () => ({
|
||||||
await new Promise<void>((resolve) => {
|
uploadTotal: 0,
|
||||||
createEffect(() => {
|
downloadTotal: 0,
|
||||||
if (selectedEndpoint()) {
|
connections: [],
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return useWsRequest<WsMsg>('connections')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const connections = createMemo(() => latestConnectionWsMessage()?.())
|
createEffect(() => {
|
||||||
|
if (selectedEndpoint()) {
|
||||||
|
connections = useWsRequest<WsMsg>('connections')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
export const useConnections = () => {
|
export const useConnections = () => {
|
||||||
const [closedConnectionsWithSpeed, setClosedConnectionsWithSpeed] =
|
const [closedConnectionsWithSpeed, setClosedConnectionsWithSpeed] =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user