diff --git a/src/components/EventFooter.tsx b/src/components/EventFooter.tsx index 9029bf8..4c8c145 100644 --- a/src/components/EventFooter.tsx +++ b/src/components/EventFooter.tsx @@ -1,6 +1,6 @@ import { NostrEvent } from "@/types/nostr"; import { KindBadge } from "./KindBadge"; -import { Wifi } from "lucide-react"; +import { Wifi, ShieldCheck } from "lucide-react"; import { getSeenRelays } from "applesauce-core/helpers/relays"; import { useAddWindow } from "@/core/state"; import { getKindName } from "@/constants/kinds"; @@ -11,6 +11,7 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { RelayLink } from "./nostr/RelayLink"; +import { isProtectedEvent } from "@/lib/nip70-helpers"; interface EventFooterProps { event: NostrEvent; @@ -38,6 +39,7 @@ export function EventFooter({ const seenRelaysSet = getSeenRelays(event); const relays = seenRelaysSet ? Array.from(seenRelaysSet) : []; const kindName = getKindName(event.kind); + const isProtected = isProtectedEvent(event); const handleKindClick = () => { // Open KIND command to show NIP documentation for this kind @@ -84,36 +86,47 @@ export function EventFooter({ )} - {/* Right: Relay Dropdown */} - {relays.length > 0 && ( - - - - - + {isProtected && ( + + )} + {relays.length > 0 && ( + + + + + + Seen on + {relays.map((relay) => ( + + ))} + + + )} + ); diff --git a/src/lib/nip70-helpers.ts b/src/lib/nip70-helpers.ts new file mode 100644 index 0000000..e0ee1d8 --- /dev/null +++ b/src/lib/nip70-helpers.ts @@ -0,0 +1,15 @@ +import type { NostrEvent } from "@/types/nostr"; +import { getOrComputeCachedValue } from "applesauce-core/helpers"; + +const IsProtectedSymbol = Symbol("isProtected"); + +/** + * Check if an event is protected (NIP-70). + * A protected event has a `["-"]` tag (single-item tag with value "-"). + * Cached on the event object via applesauce helpers. + */ +export function isProtectedEvent(event: NostrEvent): boolean { + return getOrComputeCachedValue(event, IsProtectedSymbol, () => + event.tags.some((t) => t.length === 1 && t[0] === "-"), + ); +}