mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-06 02:31:13 +02:00
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
This commit is contained in:
@@ -23,6 +23,7 @@ import type {
|
|||||||
Conversation,
|
Conversation,
|
||||||
LiveActivityMetadata,
|
LiveActivityMetadata,
|
||||||
} from "@/types/chat";
|
} from "@/types/chat";
|
||||||
|
import { CHAT_KINDS } from "@/types/chat";
|
||||||
// import { NipC7Adapter } from "@/lib/chat/adapters/nip-c7-adapter"; // Coming soon
|
// import { NipC7Adapter } from "@/lib/chat/adapters/nip-c7-adapter"; // Coming soon
|
||||||
import { Nip29Adapter } from "@/lib/chat/adapters/nip-29-adapter";
|
import { Nip29Adapter } from "@/lib/chat/adapters/nip-29-adapter";
|
||||||
import { Nip53Adapter } from "@/lib/chat/adapters/nip-53-adapter";
|
import { Nip53Adapter } from "@/lib/chat/adapters/nip-53-adapter";
|
||||||
@@ -277,10 +278,11 @@ const MessageItem = memo(function MessageItem({
|
|||||||
|
|
||||||
// Only show reply preview if:
|
// Only show reply preview if:
|
||||||
// 1. The event exists in our store
|
// 1. The event exists in our store
|
||||||
// 2. The event is a chat kind (9, 9321, 1311)
|
// 2. The event is a chat kind (includes messages, nutzaps, live chat, and zap receipts)
|
||||||
const chatKinds = [9, 9321, 1311];
|
|
||||||
const shouldShowReplyPreview =
|
const shouldShowReplyPreview =
|
||||||
zapReplyTo && replyEvent && chatKinds.includes(replyEvent.kind);
|
zapReplyTo &&
|
||||||
|
replyEvent &&
|
||||||
|
(CHAT_KINDS as readonly number[]).includes(replyEvent.kind);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="pl-2 my-1">
|
<div className="pl-2 my-1">
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
import type { NostrEvent } from "./nostr";
|
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
|
* Chat protocol identifier
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user