From dade9a79a68febf9570ebb0ef00a3cd9c82d0f84 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Thu, 15 Jan 2026 13:08:33 +0100 Subject: [PATCH] Fix chat zap preview display logic (#106) * fix: hide zap reply previews for missing or non-chat events Only show reply previews for zaps when: 1. The replied-to event exists in the event store 2. The replied-to event is a chat kind (9, 9321, or 1311) This prevents showing loading states or reply previews for zaps replying to events we don't have or non-chat events. * refactor: extract CHAT_KINDS constant and include zap receipts - Create CHAT_KINDS constant in types/chat.ts with all chat event kinds - Include kind 9735 (zap receipts) as a chat kind - Update ChatViewer to use the new constant for validation - Improves maintainability and makes it easier to update chat kinds Chat kinds now include: - 9: NIP-29 group chat messages - 9321: NIP-61 nutzaps - 1311: NIP-53 live chat messages - 9735: NIP-57 zap receipts --------- Co-authored-by: Claude --- src/components/ChatViewer.tsx | 17 ++++++++++++++++- src/types/chat.ts | 11 +++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/ChatViewer.tsx b/src/components/ChatViewer.tsx index 188f4fa..ad7c931 100644 --- a/src/components/ChatViewer.tsx +++ b/src/components/ChatViewer.tsx @@ -23,6 +23,7 @@ import type { Conversation, LiveActivityMetadata, } from "@/types/chat"; +import { CHAT_KINDS } from "@/types/chat"; // import { NipC7Adapter } from "@/lib/chat/adapters/nip-c7-adapter"; // Coming soon import { Nip29Adapter } from "@/lib/chat/adapters/nip-29-adapter"; import { Nip53Adapter } from "@/lib/chat/adapters/nip-53-adapter"; @@ -269,6 +270,20 @@ const MessageItem = memo(function MessageItem({ zapRequest?.tags.find((t) => t[0] === "e")?.[1] || undefined; + // Check if the replied-to event exists and is a chat kind + const replyEvent = use$( + () => (zapReplyTo ? eventStore.event(zapReplyTo) : undefined), + [zapReplyTo], + ); + + // Only show reply preview if: + // 1. The event exists in our store + // 2. The event is a chat kind (includes messages, nutzaps, live chat, and zap receipts) + const shouldShowReplyPreview = + zapReplyTo && + replyEvent && + (CHAT_KINDS as readonly number[]).includes(replyEvent.kind); + return (
- {zapReplyTo && ( + {shouldShowReplyPreview && (