mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-28 07:14:40 +08:00
refactor: remove SWR_REALTIME configuration and simplify SWR usage in AppDataProvider
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
||||
getRunningMode,
|
||||
getSystemProxy,
|
||||
} from "@/services/cmds";
|
||||
import { SWR_DEFAULTS, SWR_MIHOMO, SWR_REALTIME } from "@/services/config";
|
||||
import { SWR_DEFAULTS, SWR_MIHOMO } from "@/services/config";
|
||||
|
||||
import { AppDataContext, AppDataContextType } from "./app-data-context";
|
||||
|
||||
@@ -30,14 +30,7 @@ export const AppDataProvider = ({
|
||||
const { data: proxiesData, mutate: refreshProxy } = useSWR(
|
||||
"getProxies",
|
||||
calcuProxies,
|
||||
{
|
||||
...SWR_REALTIME,
|
||||
onError: (_) => {
|
||||
// FIXME when we intially start the app, and core is starting,
|
||||
// there will be error thrown by getProxies API.
|
||||
// We should handle this case properly later.
|
||||
},
|
||||
},
|
||||
SWR_MIHOMO,
|
||||
);
|
||||
|
||||
const { data: clashConfig, mutate: refreshClashConfig } = useSWR(
|
||||
|
||||
@@ -16,12 +16,6 @@ export const SWR_DEFAULTS = {
|
||||
dedupingInterval: 5000,
|
||||
} as const;
|
||||
|
||||
export const SWR_REALTIME = {
|
||||
...SWR_DEFAULTS,
|
||||
refreshInterval: 8000,
|
||||
dedupingInterval: 3000,
|
||||
} as const;
|
||||
|
||||
export const SWR_SLOW_POLL = {
|
||||
...SWR_DEFAULTS,
|
||||
refreshInterval: 60000,
|
||||
@@ -29,4 +23,6 @@ export const SWR_SLOW_POLL = {
|
||||
|
||||
export const SWR_MIHOMO = {
|
||||
...SWR_NOT_SMART,
|
||||
errorRetryInterval: 500,
|
||||
errorRetryCount: 15,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user