From 778c3a4f4b9d4185451f47c83713a8e8cfc467bc Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 20 Aug 2023 17:06:07 +0800 Subject: [PATCH] fix: fix incorrect cache key of user settings --- client/shared/hooks/model/useUserSettings.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/shared/hooks/model/useUserSettings.ts b/client/shared/hooks/model/useUserSettings.ts index 934d3124..d53ad819 100644 --- a/client/shared/hooks/model/useUserSettings.ts +++ b/client/shared/hooks/model/useUserSettings.ts @@ -16,7 +16,7 @@ import _without from 'lodash/without'; export function useUserSettings() { const client = useQueryClient(); const { data: settings, isLoading } = useQuery( - [CacheKey], + [CacheKey.userSettings], () => getUserSettings(), { staleTime: 10 * 60 * 1000, // 缓存10分钟 @@ -25,11 +25,11 @@ export function useUserSettings() { const [{ loading: saveLoading }, setSettings] = useAsyncRequest( async (settings: UserSettings) => { - client.setQueryData([CacheKey], () => settings); // 让配置能够立即生效, 防止依赖配置的行为出现跳变(如GroupNav) + client.setQueryData([CacheKey.userSettings], () => settings); // 让配置能够立即生效, 防止依赖配置的行为出现跳变(如GroupNav) const newSettings = await setUserSettings(settings); - client.setQueryData([CacheKey], () => newSettings); + client.setQueryData([CacheKey.userSettings], () => newSettings); sharedEvent.emit('userSettingsUpdate', newSettings); }, [client]