mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-12-26 19:24: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) => {
|
||||
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] =
|
||||
|
Loading…
x
Reference in New Issue
Block a user