diff --git a/components/KIND20Card.tsx b/components/KIND20Card.tsx index 051b148..c9dbd96 100644 --- a/components/KIND20Card.tsx +++ b/components/KIND20Card.tsx @@ -1,6 +1,7 @@ import type React from "react" import { useProfile } from "nostr-react" import { nip19 } from "nostr-tools" +import { useState } from "react" import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/ui/carousel" @@ -36,8 +37,9 @@ const KIND20Card: React.FC = ({ const { data: userData } = useProfile({ pubkey, }) + const [imageError, setImageError] = useState(false); - if (!image) return null; + if (!image || imageError) return null; const title = userData?.username || userData?.display_name || userData?.name || userData?.npub || nip19.npubEncode(pubkey) @@ -49,69 +51,70 @@ const KIND20Card: React.FC = ({ return ( <> - - - - - - - -
- - - - - {title} - -
-
- -

{title}

-
-
-
- -
-
- -
-
-
- {image && ( + +
+ + + + + + + +
+ + + + + {title} + +
+
+ +

{title}

+
+
+
+ +
+
+ +
+
+
{text} setImageError(true)} /> - )} +
-
-
-
{text}
-
-
-
- - - {showViewNoteCardButton && } -
-
- - +
+
{text}
+
+
+
+ + + {showViewNoteCardButton && } +
+
+ + +
-
- - -
- {createdAt.toLocaleString()} - {uploadedVia && Uploaded via {uploadedVia}} -
-
- + + +
+ {createdAt.toLocaleString()} + {uploadedVia && Uploaded via {uploadedVia}} +
+
+ +
) } diff --git a/components/ProfileFeed.tsx b/components/ProfileFeed.tsx index 5d95e9e..5d284d3 100644 --- a/components/ProfileFeed.tsx +++ b/components/ProfileFeed.tsx @@ -41,18 +41,16 @@ const ProfileFeed: React.FC = ({ pubkey }) => { {events.map((event) => { const imageUrl = getImageUrl(event.tags); return imageUrl ? ( -
- -
+ ) : null; })} {!isLoading && ( diff --git a/components/QuickViewKind20NoteCard.tsx b/components/QuickViewKind20NoteCard.tsx index 8ca2bbd..d288c4c 100644 --- a/components/QuickViewKind20NoteCard.tsx +++ b/components/QuickViewKind20NoteCard.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useProfile } from "nostr-react"; import { nip19, @@ -25,8 +25,9 @@ const QuickViewKind20NoteCard: React.FC = ({ pubke const {data, isLoading} = useProfile({ pubkey, }); + const [imageError, setImageError] = useState(false); - if (!image) return null; + if (!image || imageError) return null; text = text.replaceAll('\n', ' '); const encodedNoteId = nip19.noteEncode(event.id) @@ -45,6 +46,7 @@ const QuickViewKind20NoteCard: React.FC = ({ pubke sizes="(max-width: 768px) 100vw, 300px" className='rounded lg:rounded-lg object-cover' priority + onError={() => setImageError(true)} />