From 2772ff57545834cadbf3a929c5b58d25eb4e119d Mon Sep 17 00:00:00 2001 From: Pouria Delfanazari Date: Fri, 31 Oct 2025 10:30:28 -0700 Subject: [PATCH] fix: profile query keys --- src/webapp/features/profile/lib/profileKeys.ts | 6 ++++++ src/webapp/features/profile/lib/queries/useMyProfile.tsx | 3 ++- src/webapp/features/profile/lib/queries/useProfile.tsx | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/webapp/features/profile/lib/profileKeys.ts diff --git a/src/webapp/features/profile/lib/profileKeys.ts b/src/webapp/features/profile/lib/profileKeys.ts new file mode 100644 index 00000000..50e31418 --- /dev/null +++ b/src/webapp/features/profile/lib/profileKeys.ts @@ -0,0 +1,6 @@ +export const profileKeys = { + all: () => ['profiles'] as const, + profile: (didOrHandle: string) => + [...profileKeys.all(), didOrHandle] as const, + mine: () => [...profileKeys.all(), 'mine'] as const, +}; diff --git a/src/webapp/features/profile/lib/queries/useMyProfile.tsx b/src/webapp/features/profile/lib/queries/useMyProfile.tsx index d9b06fd0..6722b2c9 100644 --- a/src/webapp/features/profile/lib/queries/useMyProfile.tsx +++ b/src/webapp/features/profile/lib/queries/useMyProfile.tsx @@ -1,9 +1,10 @@ import { useSuspenseQuery } from '@tanstack/react-query'; import { getMyProfile } from '../dal'; +import { profileKeys } from '../profileKeys'; export default function useMyProfile() { return useSuspenseQuery({ - queryKey: ['my profile'], + queryKey: profileKeys.mine(), queryFn: () => getMyProfile(), }); } diff --git a/src/webapp/features/profile/lib/queries/useProfile.tsx b/src/webapp/features/profile/lib/queries/useProfile.tsx index 73fe2c35..fc270b8a 100644 --- a/src/webapp/features/profile/lib/queries/useProfile.tsx +++ b/src/webapp/features/profile/lib/queries/useProfile.tsx @@ -1,5 +1,6 @@ import { useSuspenseQuery } from '@tanstack/react-query'; import { getProfile } from '../dal'; +import { profileKeys } from '../profileKeys'; interface Props { didOrHandle: string; @@ -7,7 +8,7 @@ interface Props { export default function useProfile(props: Props) { const profile = useSuspenseQuery({ - queryKey: ['profile', props.didOrHandle], + queryKey: profileKeys.profile(props.didOrHandle), queryFn: () => getProfile(props.didOrHandle), }); -- 2.51.2