Skip to content

Commit 4e7f95b

Browse files
arbrandesclaude
andcommitted
perf: add enabled flag to TPA query hook to skip unnecessary fetches
In ProgressiveProfiling, the TPA query fired even when registrationEmbedded was false and the result was ignored. Added an enabled option to useThirdPartyAuthHook and set it to registrationEmbedded in ProgressiveProfiling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0a78770 commit 4e7f95b

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/common-components/data/apiHook.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import { ThirdPartyAuthQueryKeys } from './queryKeys';
66
// Error constants
77
export const THIRD_PARTY_AUTH_ERROR = 'third-party-auth-error';
88

9-
const useThirdPartyAuthHook = (pageId, payload) => useQuery({
9+
const useThirdPartyAuthHook = (pageId, payload, { enabled = true } = {}) => useQuery({
1010
queryKey: ThirdPartyAuthQueryKeys.byPage(pageId, payload),
1111
queryFn: () => getThirdPartyAuthContext(payload),
1212
retry: false,
1313
staleTime: 5 * 60 * 1000, // 5 minutes — TPA context is effectively static per session
14+
enabled,
1415
});
1516

1617
export {

src/progressive-profiling/ProgressiveProfiling.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const ProgressiveProfilingInner = () => {
7777
const [showModal, setShowModal] = useState(false);
7878

7979
const { data, isSuccess, error } = useThirdPartyAuthHook(AUTHN_PROGRESSIVE_PROFILING,
80-
{ is_welcome_page: true, next: queryParams?.next });
80+
{ is_welcome_page: true, next: queryParams?.next }, { enabled: registrationEmbedded });
8181

8282
useEffect(() => {
8383
if (registrationEmbedded) {

0 commit comments

Comments
 (0)