Skip to content

Commit

Permalink
fix: fix incorrect cache key of user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Aug 20, 2023
1 parent 0058880 commit 778c3a4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/shared/hooks/model/useUserSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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分钟
Expand All @@ -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]
Expand Down

0 comments on commit 778c3a4

Please sign in to comment.