Skip to content

Commit 282e99c

Browse files
authored
fix: set wallet avatar on popup (#1149)
1 parent b453dc2 commit 282e99c

File tree

1 file changed

+10
-2
lines changed
  • apps/browser-extension-wallet/src/features/nfts/components

1 file changed

+10
-2
lines changed

apps/browser-extension-wallet/src/features/nfts/components/NftDetail.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { useAssetInfo, useRedirection } from '@hooks';
1+
import { useAssetInfo, useRedirection, useWalletAvatar } from '@hooks';
22
import { walletRoutePaths } from '@routes';
33
import React, { useMemo } from 'react';
44
import { useParams } from 'react-router-dom';
55
import styles from './Nfts.module.scss';
6-
import { Button, Drawer, DrawerNavigation, useObservable } from '@lace/common';
6+
import { Button, Drawer, DrawerNavigation, toast, useObservable } from '@lace/common';
77
import { useWalletStore } from '@src/stores';
88
import { nftDetailSelector } from '@src/views/browser-view/features/nfts/selectors';
99
import { NftDetail as NftDetailView } from '@lace/core';
@@ -23,6 +23,7 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
2323
} = useWalletStore();
2424
const { t } = useTranslation();
2525
const analytics = useAnalyticsContext();
26+
const { setAvatar } = useWalletAvatar();
2627

2728
const redirectToNfts = useRedirection(walletRoutePaths.nfts);
2829
const redirectToSend = useRedirection<{ params: { id?: string } }>(walletRoutePaths.send);
@@ -44,6 +45,12 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
4445
redirectToSend({ params: { id } });
4546
};
4647

48+
const handleSetAsAvatar = (image: string) => {
49+
setAvatar(image);
50+
toast.notify({ text: t('core.nftDetail.avatarUpdated') });
51+
void analytics.sendEventToPostHog(PostHogAction.NFTDetailSetAsAvatarClick);
52+
};
53+
4754
return (
4855
<Drawer
4956
popupView
@@ -65,6 +72,7 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => {
6572
isPopup={appMode === APP_MODE_POPUP}
6673
amount={amount}
6774
title={<h2 className={styles.secondaryTitle}>{assetInfo.nftMetadata?.name ?? assetInfo.fingerprint}</h2>}
75+
onSetAsAvatar={handleSetAsAvatar}
6876
/>
6977
)}
7078
</Drawer>

0 commit comments

Comments
 (0)