From 20ce22fba80775f7bcc58b85ecb56f732c70ca9a Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Thu, 25 Jun 2020 15:14:56 +0800 Subject: [PATCH] Fix: read general on proxy initial --- src/containers/Proxies/index.tsx | 3 +++ src/stores/recoil.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/containers/Proxies/index.tsx b/src/containers/Proxies/index.tsx index 4af4f3c..a3ae11f 100644 --- a/src/containers/Proxies/index.tsx +++ b/src/containers/Proxies/index.tsx @@ -95,9 +95,12 @@ function ProxyProviders () { function Proxies () { const { proxies } = useProxy() + const { update: updateGeneral } = useGeneral() const { useTranslation } = useI18n() const { t } = useTranslation('Proxies') + useSWR('general', updateGeneral) + function handleNotitySpeedTest () { EE.notifySpeedTest() } diff --git a/src/stores/recoil.ts b/src/stores/recoil.ts index 8e7e6a8..3c17847 100644 --- a/src/stores/recoil.ts +++ b/src/stores/recoil.ts @@ -1,5 +1,6 @@ import { atom, useRecoilState, selector } from 'recoil' import get from 'lodash/get' +import throttle from 'lodash/throttle' import { useCallback } from 'react' import { AxiosError } from 'axios' @@ -169,7 +170,7 @@ export function useGeneral () { }) } - return { general: data, update } + return { general: data, update: throttle(update, 50) } } export const proxies = atom({