enhance image verification by adding fallback for event image hash in KIND20Card and QuickViewKind20NoteCard

This commit is contained in:
2025-04-01 18:50:57 +02:00
parent dd5725274a
commit c6bb08d8b2
2 changed files with 10 additions and 2 deletions

View File

@@ -49,7 +49,11 @@ const KIND20Card: React.FC<KIND20CardProps> = ({
const verifyImage = async () => {
try {
// get hash of the image from event tags
const eventImageHash = tags.find((tag) => tag[0] === "x")?.[1];
let eventImageHash = tags.find((tag) => tag[0] === "x")?.[1];
if(!eventImageHash) {
eventImageHash = tags.find((tag) => tag[0] === "imeta")?.find(tag => tag.startsWith("x"))?.split(" ")[1];
}
if (eventImageHash) {
// get blob from the image url

View File

@@ -42,8 +42,12 @@ const QuickViewKind20NoteCard: React.FC<QuickViewKind20NoteCardProps> = ({ pubke
const verifyImage = async () => {
try {
// get hash of the image from event tags
const eventImageHash = tags.find((tag) => tag[0] === "x")?.[1];
let eventImageHash = tags.find((tag) => tag[0] === "x")?.[1];
if(!eventImageHash) {
eventImageHash = tags.find((tag) => tag[0] === "imeta")?.find(tag => tag.startsWith("x"))?.split(" ")[1];
}
if (eventImageHash) {
// get blob from the image url
const response = await fetch(image);