Skip to content

Commit

Permalink
fix(proxy): fetch proxies after latency test
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Sep 24, 2023
1 parent 355b237 commit 81fe550
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
favNightTheme,
setCurTheme,
setLatestConnectionMsg,
useProxies,
useTwemoji,
useWsRequest,
} from '~/signals'
Expand All @@ -29,10 +28,6 @@ const Rules = lazy(() => import('~/pages/Rules'))
const Config = lazy(() => import('~/pages/Config'))

const ProtectedResources = () => {
const { fetchProxies } = useProxies()

onMount(fetchProxies)

const latestConnectionMsg = useWsRequest<WsMsg>('connections')

createEffect(() => {
Expand Down
7 changes: 5 additions & 2 deletions src/pages/Proxies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
IconReload,
IconSettings,
} from '@tabler/icons-solidjs'
import { For, Show, createMemo, createSignal } from 'solid-js'
import { For, Show, createMemo, createSignal, onMount } from 'solid-js'
import { twMerge } from 'tailwind-merge'
import {
Button,
Expand Down Expand Up @@ -38,6 +38,7 @@ export default () => {
const [t] = useI18n()

const {
fetchProxies,
proxies,
selectProxyInGroup,
latencyTestByProxyGroupName,
Expand All @@ -48,6 +49,8 @@ export default () => {
healthCheckByProviderName,
} = useProxies()

onMount(fetchProxies)

const { map: collapsedMap, set: setCollapsedMap } = useStringBooleanMap()
const { map: latencyTestingMap, setWithCallback: setLatencyTestingMap } =
useStringBooleanMap()
Expand Down Expand Up @@ -100,7 +103,7 @@ export default () => {
return (
<div class="flex h-full flex-col gap-2">
<div class="flex items-center gap-2">
<div class="tabs tabs-boxed gap-2">
<div class="tabs-boxed tabs gap-2">
<For each={tabs()}>
{(tab) => (
<button
Expand Down
3 changes: 2 additions & 1 deletion src/signals/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ export const useProxies = () => {
latencyTestTimeoutDuration(),
)

await fetchProxies()
setLatencyMap({
...latencyMap(),
...data,
})

await fetchProxies()
}

const updateProviderByProviderName = async (providerName: string) => {
Expand Down

0 comments on commit 81fe550

Please sign in to comment.