refactor: remove SWR_REALTIME configuration and simplify SWR usage in AppDataProvider

This commit is contained in:
Tunglies
2026-01-27 20:07:48 +08:00
parent 9d81a13c58
commit 36926df26c
2 changed files with 4 additions and 15 deletions

View File

@@ -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(

View File

@@ -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,
};