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 <noreply@anthropic.com>
This commit is contained in:
Alejandro
2026-01-15 13:08:33 +01:00
committed by GitHub
parent 571e7a0d14
commit dade9a79a6
2 changed files with 27 additions and 1 deletions

View File

@@ -1,5 +1,16 @@
import type { NostrEvent } from "./nostr";
/**
* Event kinds that are considered chat messages across all protocols
* Used for filtering and validating chat-related events
*/
export const CHAT_KINDS = [
9, // NIP-29: Group chat messages
9321, // NIP-61: Nutzaps (ecash zaps in groups/live chats)
1311, // NIP-53: Live chat messages
9735, // NIP-57: Zap receipts (part of chat context)
] as const;
/**
* Chat protocol identifier
*/