Skip to content

Commit

Permalink
reorg ens related calls (#5828)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobar79 authored Jun 7, 2024
1 parent 6642231 commit ca22bfd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
22 changes: 10 additions & 12 deletions src/components/cards/ENSCreateProfileCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useCallback, useEffect } from 'react';
import ENSAvatarGrid from '../../assets/ensAvatarGrid.png';
import ENSIcon from '../../assets/ensIcon.png';
import { useNavigation } from '../../navigation/Navigation';
Expand Down Expand Up @@ -33,8 +33,15 @@ export const ENSCreateProfileCard = () => {
// 40 represents the horizontal padding outside the card
const imageWidth = deviceWidth - 40;

const handlePress = () => {
const { uniqueDomain } = useAccountENSDomains();

const handlePress = useCallback(() => {
if (!isReadOnlyWallet || enableActionsOnReadOnlyWallet) {
if (uniqueDomain?.name) {
prefetchENSAvatar(uniqueDomain.name);
prefetchENSRecords(uniqueDomain.name);
}

analyticsV2.track(analyticsV2.event.cardPressed, {
cardName: 'ENSCreateProfileCard',
routeName,
Expand All @@ -46,16 +53,7 @@ export const ENSCreateProfileCard = () => {
} else {
watchingAlert();
}
};

const { uniqueDomain } = useAccountENSDomains();

useEffect(() => {
if (uniqueDomain?.name) {
prefetchENSAvatar(uniqueDomain.name);
prefetchENSRecords(uniqueDomain.name);
}
}, [uniqueDomain]);
}, [isReadOnlyWallet, navigate, routeName, uniqueDomain?.name]);

return (
<ColorModeProvider value="lightTinted">
Expand Down
14 changes: 6 additions & 8 deletions src/hooks/useOnAvatarPress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ export default ({ screenType = 'transaction' }: UseOnAvatarPressProps = {}) => {
const { startRegistration } = useENSRegistration();
const { setNextEmoji } = useUpdateEmoji();

useEffect(() => {
if (accountENS) {
prefetchENSAvatar(accountENS);
prefetchENSCover(accountENS);
prefetchENSRecords(accountENS);
}
}, [accountENS]);

const onAvatarRemovePhoto = useCallback(async () => {
const newWallets: typeof wallets = {
...wallets,
Expand Down Expand Up @@ -256,6 +248,12 @@ export default ({ screenType = 'transaction' }: UseOnAvatarPressProps = {}) => {
}, [accountENS, navigate]);

const onAvatarPress = useCallback(() => {
if (accountENS) {
prefetchENSAvatar(accountENS);
prefetchENSCover(accountENS);
prefetchENSRecords(accountENS);
}

if (hasENSAvatar && accountENS) {
onAvatarPressProfile();
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/redux/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ export const walletsLoadState =
type: WALLETS_LOAD,
});

dispatch(fetchWalletNames());
profilesEnabled && dispatch(fetchWalletENSAvatars());
return wallets;
} catch (error) {
logger.error(new RainbowError('Exception during walletsLoadState'), {
Expand Down

0 comments on commit ca22bfd

Please sign in to comment.