refactor: optimize swr data refresh paths

This commit is contained in:
Tunglies
2026-06-28 19:42:21 +08:00
parent e71e701fd0
commit b9da0875cd
16 changed files with 153 additions and 162 deletions
+3 -5
View File
@@ -1,7 +1,7 @@
import { useEffect } from 'react'
import { useListen } from '@/hooks/use-listen'
import { queryClient } from '@/services/query-client'
import { revalidateQueries } from '@/services/query-client'
export const useLayoutEvents = (
handleNotice: (payload: [string, string]) => void,
@@ -12,9 +12,7 @@ export const useLayoutEvents = (
const unlisteners: Array<() => void> = []
let disposed = false
const revalidateKeys = (keys: readonly string[]) => {
keys.forEach((key) => {
queryClient.invalidateQueries({ queryKey: [key] })
})
void revalidateQueries(keys.map((key) => [key]))
}
const register = (
@@ -42,7 +40,7 @@ export const useLayoutEvents = (
}
register(
addListener('verge://refresh-clash-config', async () => {
addListener('verge://refresh-clash-config', () => {
revalidateKeys([
'getProxies',
'getVersion',