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>
This commit is contained in:
committed by
Adolfo R. Brandes
parent
8dcf55254e
commit
86b4ea79de
@@ -6,11 +6,12 @@ import { ThirdPartyAuthQueryKeys } from './queryKeys';
|
||||
// Error constants
|
||||
export const THIRD_PARTY_AUTH_ERROR = 'third-party-auth-error';
|
||||
|
||||
const useThirdPartyAuthHook = (pageId, payload) => useQuery({
|
||||
const useThirdPartyAuthHook = (pageId, payload, { enabled = true } = {}) => useQuery({
|
||||
queryKey: ThirdPartyAuthQueryKeys.byPage(pageId, payload),
|
||||
queryFn: () => getThirdPartyAuthContext(payload),
|
||||
retry: false,
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes — TPA context is effectively static per session
|
||||
enabled,
|
||||
});
|
||||
|
||||
export {
|
||||
|
||||
@@ -77,7 +77,7 @@ const ProgressiveProfilingInner = () => {
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
|
||||
const { data, isSuccess, error } = useThirdPartyAuthHook(AUTHN_PROGRESSIVE_PROFILING,
|
||||
{ is_welcome_page: true, next: queryParams?.next });
|
||||
{ is_welcome_page: true, next: queryParams?.next }, { enabled: registrationEmbedded });
|
||||
|
||||
useEffect(() => {
|
||||
if (registrationEmbedded) {
|
||||
|
||||
Reference in New Issue
Block a user