From 282e99c27a9bb5c91028192c8b5d14dc7c083db7 Mon Sep 17 00:00:00 2001 From: John Oshalusi Date: Fri, 10 May 2024 13:18:13 +0100 Subject: [PATCH] fix: set wallet avatar on popup (#1149) --- .../src/features/nfts/components/NftDetail.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/browser-extension-wallet/src/features/nfts/components/NftDetail.tsx b/apps/browser-extension-wallet/src/features/nfts/components/NftDetail.tsx index 2d56dfe25..29c0d7f11 100644 --- a/apps/browser-extension-wallet/src/features/nfts/components/NftDetail.tsx +++ b/apps/browser-extension-wallet/src/features/nfts/components/NftDetail.tsx @@ -1,9 +1,9 @@ -import { useAssetInfo, useRedirection } from '@hooks'; +import { useAssetInfo, useRedirection, useWalletAvatar } from '@hooks'; import { walletRoutePaths } from '@routes'; import React, { useMemo } from 'react'; import { useParams } from 'react-router-dom'; import styles from './Nfts.module.scss'; -import { Button, Drawer, DrawerNavigation, useObservable } from '@lace/common'; +import { Button, Drawer, DrawerNavigation, toast, useObservable } from '@lace/common'; import { useWalletStore } from '@src/stores'; import { nftDetailSelector } from '@src/views/browser-view/features/nfts/selectors'; import { NftDetail as NftDetailView } from '@lace/core'; @@ -23,6 +23,7 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => { } = useWalletStore(); const { t } = useTranslation(); const analytics = useAnalyticsContext(); + const { setAvatar } = useWalletAvatar(); const redirectToNfts = useRedirection(walletRoutePaths.nfts); const redirectToSend = useRedirection<{ params: { id?: string } }>(walletRoutePaths.send); @@ -44,6 +45,12 @@ export const NftDetail = withNftsFoldersContext((): React.ReactElement => { redirectToSend({ params: { id } }); }; + const handleSetAsAvatar = (image: string) => { + setAvatar(image); + toast.notify({ text: t('core.nftDetail.avatarUpdated') }); + void analytics.sendEventToPostHog(PostHogAction.NFTDetailSetAsAvatarClick); + }; + return ( { isPopup={appMode === APP_MODE_POPUP} amount={amount} title={

{assetInfo.nftMetadata?.name ?? assetInfo.fingerprint}

} + onSetAsAvatar={handleSetAsAvatar} /> )}