mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-10 23:47:12 +02:00
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.
This commit is contained in:
@@ -269,6 +269,19 @@ 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 (9, 9321, 1311)
|
||||
const chatKinds = [9, 9321, 1311];
|
||||
const shouldShowReplyPreview =
|
||||
zapReplyTo && replyEvent && chatKinds.includes(replyEvent.kind);
|
||||
|
||||
return (
|
||||
<div className="pl-2 my-1">
|
||||
<div
|
||||
@@ -300,7 +313,7 @@ const MessageItem = memo(function MessageItem({
|
||||
<Timestamp timestamp={message.timestamp} />
|
||||
</span>
|
||||
</div>
|
||||
{zapReplyTo && (
|
||||
{shouldShowReplyPreview && (
|
||||
<ReplyPreview
|
||||
replyToId={zapReplyTo}
|
||||
adapter={adapter}
|
||||
|
||||
Reference in New Issue
Block a user