mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-09 15:07:10 +02:00
fix: hide embeds in replies
This commit is contained in:
@@ -30,6 +30,8 @@ export interface RichTextOptions {
|
||||
showAudio?: boolean;
|
||||
/** Convenience flag to disable all media at once (default: true) */
|
||||
showMedia?: boolean;
|
||||
/** Show event embeds for note/nevent/naddr mentions (default: true) */
|
||||
showEventEmbeds?: boolean;
|
||||
}
|
||||
|
||||
// Default options
|
||||
@@ -38,6 +40,7 @@ const defaultOptions: Required<RichTextOptions> = {
|
||||
showVideos: true,
|
||||
showAudio: true,
|
||||
showMedia: true,
|
||||
showEventEmbeds: true,
|
||||
};
|
||||
|
||||
// Context for passing options through RichText rendering
|
||||
|
||||
@@ -2,7 +2,7 @@ import { kinds } from "nostr-tools";
|
||||
import { UserName } from "../UserName";
|
||||
import { EventEmbed } from "./EventEmbed";
|
||||
import { EventPointer, AddressPointer } from "nostr-tools/nip19";
|
||||
import { useDepth } from "../RichText";
|
||||
import { useDepth, useRichTextOptions } from "../RichText";
|
||||
|
||||
interface MentionNodeProps {
|
||||
node: {
|
||||
@@ -16,6 +16,7 @@ interface MentionNodeProps {
|
||||
|
||||
export function Mention({ node }: MentionNodeProps) {
|
||||
const depth = useDepth();
|
||||
const options = useRichTextOptions();
|
||||
|
||||
if (node.decoded?.type === "npub") {
|
||||
const pubkey = node.decoded.data;
|
||||
@@ -46,16 +47,43 @@ export function Mention({ node }: MentionNodeProps) {
|
||||
kind: kinds.ShortTextNote,
|
||||
relays: [],
|
||||
};
|
||||
|
||||
if (!options.showEventEmbeds) {
|
||||
return (
|
||||
<span className="text-muted-foreground font-mono text-sm">
|
||||
{node.encoded || `note:${pointer.id.slice(0, 8)}...`}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return <EventEmbed node={{ pointer }} depth={depth} />;
|
||||
}
|
||||
|
||||
if (node.decoded?.type === "nevent") {
|
||||
const pointer: EventPointer = node.decoded.data;
|
||||
|
||||
if (!options.showEventEmbeds) {
|
||||
return (
|
||||
<span className="text-muted-foreground font-mono text-sm">
|
||||
{node.encoded || `nevent:${pointer.id.slice(0, 8)}...`}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return <EventEmbed node={{ pointer }} depth={depth} />;
|
||||
}
|
||||
|
||||
if (node.decoded?.type === "naddr") {
|
||||
const pointer: AddressPointer = node.decoded.data;
|
||||
|
||||
if (!options.showEventEmbeds) {
|
||||
return (
|
||||
<span className="text-muted-foreground font-mono text-sm">
|
||||
{node.encoded || `naddr:${pointer.identifier || pointer.pubkey.slice(0, 8)}...`}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return <EventEmbed node={{ pointer }} depth={depth} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,10 @@ export function Kind1Renderer({ event, depth = 0 }: BaseEventProps) {
|
||||
className="flex-shrink-0 text-accent"
|
||||
/>
|
||||
<div className="truncate line-clamp-1">
|
||||
<RichText event={parentEvent} options={{ showMedia: false }} />
|
||||
<RichText
|
||||
event={parentEvent}
|
||||
options={{ showMedia: false, showEventEmbeds: false }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -49,7 +49,10 @@ export function Kind9Renderer({ event, depth = 0 }: BaseEventProps) {
|
||||
className="flex-shrink-0 text-accent"
|
||||
/>
|
||||
<div className="truncate line-clamp-1">
|
||||
<RichText event={parentEvent} options={{ showMedia: false }} />
|
||||
<RichText
|
||||
event={parentEvent}
|
||||
options={{ showMedia: false, showEventEmbeds: false }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user