Skip to content

Commit

Permalink
prefetch
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkas committed Aug 21, 2024
1 parent 7b84f2e commit fa7c2d5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions apps/web/src/components/Basenames/RegistrationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,17 @@ export default function RegistrationProvider({ children }: RegistrationProviderP
});
}, 1500);

const redirectToProfile = useCallback(() => {
const profilePath = useMemo(() => {
if (basenameChain.id === base.id) {
router.push(`name/${selectedName}`);
return `name/${selectedName}`;
} else {
router.push(`name/${formatBaseEthDomain(selectedName, basenameChain.id)}`);
return `name/${formatBaseEthDomain(selectedName, basenameChain.id)}`;
}
}, [basenameChain.id, router, selectedName]);
}, [basenameChain.id, selectedName]);

const redirectToProfile = useCallback(() => {
router.push(profilePath);
}, [profilePath, router]);

useEffect(() => {
if (transactionIsFetching && registrationStep === RegistrationSteps.Claim) {
Expand All @@ -186,6 +190,7 @@ export default function RegistrationProvider({ children }: RegistrationProviderP
if (transactionData.status === 'success') {
logEventWithContext('register_name_transaction_success', ActionType.change);
setRegistrationStep(RegistrationSteps.Success);
router.prefetch(profilePath);
}

if (transactionData.status === 'reverted') {
Expand All @@ -197,7 +202,9 @@ export default function RegistrationProvider({ children }: RegistrationProviderP
}, [
baseEnsNameRefetch,
logEventWithContext,
profilePath,
registrationStep,
router,
transactionData,
transactionIsFetching,
transactionIsSuccess,
Expand Down

0 comments on commit fa7c2d5

Please sign in to comment.