From b2b155888460385dcd55e40a2ddfc4d28a011e37 Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Wed, 18 Dec 2024 08:49:34 +0100 Subject: [PATCH] feat(ledger): ui to ignore inscriptions --- .../bitcoin/high-sat-value-utxo.tsx | 20 +++ .../components/bitcoin/inscription.tsx | 149 ++++++++++-------- .../components/bitcoin/ordinals.tsx | 2 +- 3 files changed, 105 insertions(+), 66 deletions(-) create mode 100644 src/app/features/collectibles/components/bitcoin/high-sat-value-utxo.tsx diff --git a/src/app/features/collectibles/components/bitcoin/high-sat-value-utxo.tsx b/src/app/features/collectibles/components/bitcoin/high-sat-value-utxo.tsx new file mode 100644 index 00000000000..c84cc370be4 --- /dev/null +++ b/src/app/features/collectibles/components/bitcoin/high-sat-value-utxo.tsx @@ -0,0 +1,20 @@ +import { Box, Circle } from 'leather-styles/jsx'; + +import type { Inscription } from '@leather.io/models'; + +import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip'; + +interface HighSatValueUtxoProps { + inscription: Inscription; +} + +export function HighSatValueUtxoWarning({ inscription }: HighSatValueUtxoProps) { + if (Number(inscription.value) < 5_000) return null; + return ( + + + + + + ); +} diff --git a/src/app/features/collectibles/components/bitcoin/inscription.tsx b/src/app/features/collectibles/components/bitcoin/inscription.tsx index bdb1a54d40a..bf1ee542018 100644 --- a/src/app/features/collectibles/components/bitcoin/inscription.tsx +++ b/src/app/features/collectibles/components/bitcoin/inscription.tsx @@ -1,5 +1,8 @@ +import { useCallback, useMemo } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; +import { Box } from 'leather-styles/jsx'; + import { type Inscription } from '@leather.io/models'; import { OrdinalAvatarIcon } from '@leather.io/ui'; @@ -12,6 +15,7 @@ import { CollectibleAudio } from '../_collectible-types/collectible-audio'; import { CollectibleIframe } from '../_collectible-types/collectible-iframe'; import { CollectibleImage } from '../_collectible-types/collectible-image'; import { CollectibleOther } from '../_collectible-types/collectible-other'; +import { HighSatValueUtxoWarning } from './high-sat-value-utxo'; import { InscriptionText } from './inscription-text'; interface InscriptionProps { @@ -26,73 +30,88 @@ export function Inscription({ inscription }: InscriptionProps) { const navigate = useNavigate(); const location = useLocation(); - function openSendInscriptionModal() { + const openSendInscriptionModal = useCallback(() => { navigate(RouteUrls.SendOrdinalInscription, { state: { inscription, backgroundLocation: location }, }); - } + }, [navigate, inscription, location]); + + const content = useMemo(() => { + switch (inscription.mimeType) { + case 'audio': + return ( + } + key={inscription.title} + onClickCallToAction={() => openInscriptionUrl(inscription.number)} + onClickSend={() => openSendInscriptionModal()} + subtitle="Ordinal inscription" + title={`# ${inscription.number}`} + /> + ); + case 'html': + case 'svg': + case 'video': + case 'gltf': + return ( + } + key={inscription.title} + onClickCallToAction={() => openInscriptionUrl(inscription.number)} + onClickSend={() => openSendInscriptionModal()} + src={inscription.src} + subtitle="Ordinal inscription" + title={`# ${inscription.number}`} + /> + ); + case 'image': + return ( + } + key={inscription.title} + onClickCallToAction={() => openInscriptionUrl(inscription.number)} + onClickSend={() => openSendInscriptionModal()} + src={inscription.src} + subtitle="Ordinal inscription" + title={`# ${inscription.number}`} + /> + ); + case 'text': + return ( + openInscriptionUrl(inscription.number)} + onClickSend={() => openSendInscriptionModal()} + /> + ); + case 'other': + return ( + openInscriptionUrl(inscription.number)} + onClickSend={() => openSendInscriptionModal()} + subtitle="Ordinal inscription" + title={`# ${inscription.number}`} + > + + + ); + default: + return null; + } + }, [ + inscription.mimeType, + inscription.number, + inscription.src, + inscription.title, + openSendInscriptionModal, + ]); - switch (inscription.mimeType) { - case 'audio': - return ( - } - key={inscription.title} - onClickCallToAction={() => openInscriptionUrl(inscription.number)} - onClickSend={() => openSendInscriptionModal()} - subtitle="Ordinal inscription" - title={`# ${inscription.number}`} - /> - ); - case 'html': - case 'svg': - case 'video': - case 'gltf': - return ( - } - key={inscription.title} - onClickCallToAction={() => openInscriptionUrl(inscription.number)} - onClickSend={() => openSendInscriptionModal()} - src={inscription.src} - subtitle="Ordinal inscription" - title={`# ${inscription.number}`} - /> - ); - case 'image': - return ( - } - key={inscription.title} - onClickCallToAction={() => openInscriptionUrl(inscription.number)} - onClickSend={() => openSendInscriptionModal()} - src={inscription.src} - subtitle="Ordinal inscription" - title={`# ${inscription.number}`} - /> - ); - case 'text': - return ( - openInscriptionUrl(inscription.number)} - onClickSend={() => openSendInscriptionModal()} - /> - ); - case 'other': - return ( - openInscriptionUrl(inscription.number)} - onClickSend={() => openSendInscriptionModal()} - subtitle="Ordinal inscription" - title={`# ${inscription.number}`} - > - - - ); - default: - return null; - } + return ( + + {content} + + + ); } diff --git a/src/app/features/collectibles/components/bitcoin/ordinals.tsx b/src/app/features/collectibles/components/bitcoin/ordinals.tsx index dd176f16233..bbb0db4a91b 100644 --- a/src/app/features/collectibles/components/bitcoin/ordinals.tsx +++ b/src/app/features/collectibles/components/bitcoin/ordinals.tsx @@ -18,8 +18,8 @@ export function Ordinals() { void analytics.track('view_collectibles', { ordinals_count: inscriptionsLength, }); - void analytics.identify({ ordinals_count: inscriptionsLength }); } + void analytics.identify({ ordinals_count: inscriptionsLength }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [results.inscriptions?.length]);