import useSWR, { useSWRConfig } from "swr"; import { useEffect } from "react"; import { List, Paper } from "@mui/material"; import { getProxies } from "../services/api"; import BasePage from "../components/base-page"; import ProxyItem from "../components/proxy-item"; import ProxyGroup from "../components/proxy-group"; const ProxyPage = () => { const { mutate } = useSWRConfig(); const { data: proxiesData } = useSWR("getProxies", getProxies); const { groups = [], proxies = [] } = 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 ( {groups.length > 0 && ( {groups.map((group) => ( ))} )} {!groups.length && ( {Object.values(proxies).map((proxy) => ( ))} )} ); }; export default ProxyPage;