mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-10 05:15:35 +08:00
perf: batch signals
This commit is contained in:
parent
d3ae853aa9
commit
e04ec712ea
@ -131,7 +131,7 @@ export default () => {
|
||||
})
|
||||
|
||||
return (
|
||||
<div class="mx-auto flex max-w-screen-md flex-col items-center gap-4 py-10">
|
||||
<div class="mx-auto flex max-w-screen-sm flex-col items-center gap-4 py-10">
|
||||
<form class="contents" use:form={form}>
|
||||
<div class="flex w-full flex-col gap-4">
|
||||
<div class="flex-1">
|
||||
@ -165,20 +165,20 @@ export default () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button type="submit" class="btn-primary join-item uppercase">
|
||||
<Button type="submit" class="btn-primary uppercase">
|
||||
{t('add')}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="flex w-full flex-col gap-4">
|
||||
<div class="grid w-full grid-cols-2 gap-4">
|
||||
<For each={endpointList()}>
|
||||
{({ id, url }) => (
|
||||
<div
|
||||
class="badge badge-info flex w-full cursor-pointer items-center gap-4 py-4"
|
||||
class="badge badge-info flex w-full cursor-pointer items-center justify-between gap-4 py-4"
|
||||
onClick={() => onEndpointSelect(id)}
|
||||
>
|
||||
{url}
|
||||
<span class="truncate">{url}</span>
|
||||
|
||||
<Button
|
||||
class="btn-circle btn-ghost btn-xs text-white"
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createSignal, untrack } from 'solid-js'
|
||||
import { batch, createSignal, untrack } from 'solid-js'
|
||||
import {
|
||||
closeSingleConnectionAPI,
|
||||
fetchProxiesAPI,
|
||||
@ -10,6 +10,7 @@ import {
|
||||
} from '~/apis'
|
||||
import {
|
||||
autoCloseConns,
|
||||
latencyQualityMap,
|
||||
latencyTestTimeoutDuration,
|
||||
latestConnectionMsg,
|
||||
mergeAllConnections,
|
||||
@ -40,7 +41,8 @@ const setProxiesInfo = (proxies: (Proxy | ProxyNode)[]) => {
|
||||
const newLatencyMap = { ...latencyMap() }
|
||||
|
||||
proxies.forEach((proxy) => {
|
||||
const latency = proxy.history.at(-1)?.delay || -1
|
||||
const latency =
|
||||
proxy.history.at(-1)?.delay || latencyQualityMap().NOT_CONNECTED
|
||||
|
||||
newProxyNodeMap[proxy.name] = {
|
||||
udp: proxy.udp,
|
||||
@ -52,8 +54,10 @@ const setProxiesInfo = (proxies: (Proxy | ProxyNode)[]) => {
|
||||
newLatencyMap[proxy.name] = latency
|
||||
})
|
||||
|
||||
setProxyNodeMap(newProxyNodeMap)
|
||||
setLatencyMap(newLatencyMap)
|
||||
batch(() => {
|
||||
setProxyNodeMap(newProxyNodeMap)
|
||||
setLatencyMap(newLatencyMap)
|
||||
})
|
||||
}
|
||||
|
||||
export const useProxies = () => {
|
||||
@ -79,9 +83,11 @@ export const useProxies = () => {
|
||||
...sortedProviders.flatMap((provider) => provider.proxies),
|
||||
]
|
||||
|
||||
setProxies(sortedProxies)
|
||||
setProxyProviders(sortedProviders)
|
||||
setProxiesInfo(allProxies)
|
||||
batch(() => {
|
||||
setProxies(sortedProxies)
|
||||
setProxyProviders(sortedProviders)
|
||||
setProxiesInfo(allProxies)
|
||||
})
|
||||
}
|
||||
|
||||
const setProxyGroupByProxyName = async (proxy: Proxy, proxyName: string) => {
|
||||
|
Loading…
Reference in New Issue
Block a user