mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-09 15:07:10 +02:00
fix: remove redundant reply preview for NIP-10 root replies (#163)
* fix: remove redundant reply preview for NIP-10 root replies In NIP-10 thread chats, messages replying directly to the thread root no longer show a reply preview, since replying to the root is implicit in the thread chat context. Reply previews are still shown for replies to other messages within the thread, maintaining proper conversation threading. Changes: - Modified eventToMessage() in nip-10-adapter.ts to only set replyTo when a message has a NIP-10 "reply" marker (replying to another message) - Messages with only a "root" marker now have replyTo=undefined - Prefixed unused rootEventId parameter with underscore to fix lint warning * fix: hide reply button and menu for NIP-10 root message In NIP-10 thread chats, the root message now cannot be replied to directly, as all messages in the thread are implicitly replies to the root. Changes: - Added isRootMessage prop to MessageItem component - Hide reply button when message is the root message - Remove reply option from context menu for root message - Root message check: protocol === "nip-10" && message ID matches rootEventId * revert: restore reply preview logic in NIP-10 adapter Reverted changes to eventToMessage() that removed reply previews for root replies. The UI-level hiding of reply interactions on the root message is sufficient - reply previews can still be shown for consistency with other messages. Changes: - Restored rootEventId parameter (removed underscore prefix) - Restored full reply detection logic (reply, root, or fallback) - Reply previews now shown for all replies including root replies * chore: remove tsconfig.node.tsbuildinfo from repository This build artifact is already gitignored (*.tsbuildinfo) but was previously committed. Removing it from the repository as it should not be tracked in version control. --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -262,6 +262,7 @@ const MessageItem = memo(function MessageItem({
|
||||
onReply,
|
||||
canReply,
|
||||
onScrollToMessage,
|
||||
isRootMessage,
|
||||
}: {
|
||||
message: Message;
|
||||
adapter: ChatProtocolAdapter;
|
||||
@@ -269,6 +270,7 @@ const MessageItem = memo(function MessageItem({
|
||||
onReply?: (messageId: string) => void;
|
||||
canReply: boolean;
|
||||
onScrollToMessage?: (messageId: string) => void;
|
||||
isRootMessage?: boolean;
|
||||
}) {
|
||||
// Get relays for this conversation (memoized to prevent unnecessary re-subscriptions)
|
||||
const relays = useMemo(
|
||||
@@ -377,7 +379,7 @@ const MessageItem = memo(function MessageItem({
|
||||
</span>
|
||||
{/* Reactions display - inline after timestamp */}
|
||||
<MessageReactions messageId={message.id} relays={relays} />
|
||||
{canReply && onReply && (
|
||||
{canReply && onReply && !isRootMessage && (
|
||||
<button
|
||||
onClick={() => onReply(message.id)}
|
||||
className="opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-foreground ml-auto"
|
||||
@@ -414,7 +416,11 @@ const MessageItem = memo(function MessageItem({
|
||||
return (
|
||||
<ChatMessageContextMenu
|
||||
event={message.event}
|
||||
onReply={canReply && onReply ? () => onReply(message.id) : undefined}
|
||||
onReply={
|
||||
canReply && onReply && !isRootMessage
|
||||
? () => onReply(message.id)
|
||||
: undefined
|
||||
}
|
||||
conversation={conversation}
|
||||
adapter={adapter}
|
||||
message={message}
|
||||
@@ -1027,6 +1033,11 @@ export function ChatViewer({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// For NIP-10 threads, check if this is the root message
|
||||
const isRootMessage =
|
||||
protocol === "nip-10" &&
|
||||
conversation.metadata?.rootEventId === item.data.id;
|
||||
|
||||
return (
|
||||
<MessageItem
|
||||
key={item.data.id}
|
||||
@@ -1036,6 +1047,7 @@ export function ChatViewer({
|
||||
onReply={handleReply}
|
||||
canReply={canSign}
|
||||
onScrollToMessage={handleScrollToMessage}
|
||||
isRootMessage={isRootMessage}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"root":["./vite.config.ts"],"errors":true,"version":"5.9.3"}
|
||||
Reference in New Issue
Block a user