From 72c2b306cf294ca1c02ae36b85e823a9a54a0eeb Mon Sep 17 00:00:00 2001 From: GyDi Date: Mon, 10 Jan 2022 21:25:41 +0800 Subject: [PATCH] fix: get proxies multiple times --- src/pages/proxy.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/proxy.tsx b/src/pages/proxy.tsx index e4a1e2d..6e2fc86 100644 --- a/src/pages/proxy.tsx +++ b/src/pages/proxy.tsx @@ -1,12 +1,22 @@ -import useSWR from "swr"; +import useSWR, { useSWRConfig } from "swr"; +import { useEffect } from "react"; import { Box, List, Paper, Typography } from "@mui/material"; import { getProxies } from "../services/api"; import ProxyGroup from "../components/proxy-group"; const ProxyPage = () => { + const { mutate } = useSWRConfig(); const { data: proxiesData } = useSWR("getProxies", getProxies); const { groups = [] } = proxiesData ?? {}; + useEffect(() => { + // fix the empty proxies on the first sight + // this bud only show on the build version + // call twice to avoid something unknown or the delay of the clash startup + setTimeout(() => mutate("getProxies"), 250); + setTimeout(() => mutate("getProxies"), 1000); + }, []); + return (