diff --git a/src/components/IPv6Support.tsx b/src/components/IPv6Support.tsx
index 932cf6a..da315a7 100644
--- a/src/components/IPv6Support.tsx
+++ b/src/components/IPv6Support.tsx
@@ -1,7 +1,7 @@
import { useProxies } from '~/signals'
import { proxyIPv6SupportMap } from '~/signals/ipv6'
-export const IPv6Support = (props: { name?: string; class?: string }) => {
+export const IPv6Support = (props: { name?: string }) => {
const { getNowProxyNodeName } = useProxies()
const support = createMemo(() => {
@@ -10,7 +10,7 @@ export const IPv6Support = (props: { name?: string; class?: string }) => {
return (
- IPv6
+ IPv6
)
}
diff --git a/src/components/Latency.tsx b/src/components/Latency.tsx
index dd042d9..73b6902 100644
--- a/src/components/Latency.tsx
+++ b/src/components/Latency.tsx
@@ -4,10 +4,10 @@ import { latencyQualityMap, useProxies } from '~/signals'
export const Latency = (props: { name?: string; class?: string }) => {
const [t] = useI18n()
- const { getNowProxyNodeName, latencyMap } = useProxies()
+ const { getLatencyByName } = useProxies()
const [textClassName, setTextClassName] = createSignal('')
const latency = createMemo(() => {
- return latencyMap()[getNowProxyNodeName(props.name || '')]
+ return getLatencyByName(props.name || '')
})
createEffect(() => {
diff --git a/src/components/ProxyPreviewBar.tsx b/src/components/ProxyPreviewBar.tsx
index 756ad69..6f68d09 100644
--- a/src/components/ProxyPreviewBar.tsx
+++ b/src/components/ProxyPreviewBar.tsx
@@ -5,9 +5,9 @@ export const ProxyPreviewBar = (props: {
proxyNameList: string[]
now?: string
}) => {
- const { latencyMap } = useProxies()
+ const { getLatencyByName } = useProxies()
const latencyList = createMemo(() =>
- props.proxyNameList.map((name) => latencyMap()[name]),
+ props.proxyNameList.map((name) => getLatencyByName(name)),
)
const all = createMemo(() => latencyList().length)
diff --git a/src/components/ProxyPreviewDots.tsx b/src/components/ProxyPreviewDots.tsx
index 1bf3015..18b2bde 100644
--- a/src/components/ProxyPreviewDots.tsx
+++ b/src/components/ProxyPreviewDots.tsx
@@ -40,7 +40,7 @@ export const ProxyPreviewDots = (props: {
proxyNameList: string[]
now?: string
}) => {
- const { latencyMap } = useProxies()
+ const { getLatencyByName } = useProxies()
return (
@@ -48,7 +48,7 @@ export const ProxyPreviewDots = (props: {
[
name,
- latencyMap()[name],
+ getLatencyByName(name),
])}
>
{([name, latency]) => {
diff --git a/src/constants/index.ts b/src/constants/index.ts
index e22172a..a07de63 100644
--- a/src/constants/index.ts
+++ b/src/constants/index.ts
@@ -80,13 +80,13 @@ export const DEFAULT_CHART_OPTIONS: ApexOptions = {
}
export enum LATENCY_QUALITY_MAP_HTTP {
- NOT_CONNECTED = -1,
+ NOT_CONNECTED = 0,
MEDIUM = 200,
HIGH = 500,
}
export enum LATENCY_QUALITY_MAP_HTTPS {
- NOT_CONNECTED = -1,
+ NOT_CONNECTED = 0,
MEDIUM = 800,
HIGH = 1500,
}
diff --git a/src/helpers/proxies.ts b/src/helpers/proxies.ts
index 4077367..5ed37cd 100644
--- a/src/helpers/proxies.ts
+++ b/src/helpers/proxies.ts
@@ -1,5 +1,5 @@
import { PROXIES_ORDERING_TYPE } from '~/constants'
-import { latencyQualityMap } from '~/signals'
+import { latencyQualityMap, useProxies } from '~/signals'
export const formatProxyType = (type = '') => {
const t = type.toLowerCase()
@@ -36,21 +36,17 @@ export const filterSpecialProxyType = (type = '') => {
export const sortProxiesByOrderingType = (
proxyNames: string[],
- proxyLatencyMap: Record,
orderingType: PROXIES_ORDERING_TYPE,
- proxyGroupNames: Set | undefined,
) => {
+ const { getLatencyByName } = useProxies()
+
if (orderingType === PROXIES_ORDERING_TYPE.NATURAL) {
return proxyNames
}
return proxyNames.sort((a, b) => {
- if (proxyGroupNames?.has(a) && !proxyGroupNames?.has(b)) return -1
-
- if (proxyGroupNames?.has(b) && !proxyGroupNames?.has(a)) return 1
-
- const prevLatency = proxyLatencyMap[a]
- const nextLatency = proxyLatencyMap[b]
+ const prevLatency = getLatencyByName(a)
+ const nextLatency = getLatencyByName(b)
switch (orderingType) {
case PROXIES_ORDERING_TYPE.LATENCY_ASC:
@@ -81,14 +77,13 @@ export const sortProxiesByOrderingType = (
export const filterProxiesByAvailability = (
proxyNames: string[],
- proxyLatencyMap: Record,
- excludes: Set,
enabled?: boolean,
-) =>
- enabled
- ? proxyNames.filter((name) =>
- excludes?.has(name)
- ? true
- : proxyLatencyMap[name] !== latencyQualityMap().NOT_CONNECTED,
+) => {
+ const { getLatencyByName } = useProxies()
+
+ return enabled
+ ? proxyNames.filter(
+ (name) => getLatencyByName(name) !== latencyQualityMap().NOT_CONNECTED,
)
: proxyNames
+}
diff --git a/src/pages/Connections.tsx b/src/pages/Connections.tsx
index 653b332..0124bc1 100644
--- a/src/pages/Connections.tsx
+++ b/src/pages/Connections.tsx
@@ -358,13 +358,13 @@ export default () => {
-
+
{(tab) => (