fix: ensure $hashtags alias works with kind 777 spells

- Pass needsInterestList prop to ReqViewer in WindowRenderer
- Add HashtagsPlaceholder component to SpellRenderer for visual
  representation of $hashtags in spell filters (similar to
  MePlaceholder and ContactsPlaceholder)
This commit is contained in:
Claude
2026-01-13 09:11:38 +00:00
parent 2f202286db
commit 4cae2bee41
2 changed files with 62 additions and 2 deletions

View File

@@ -148,6 +148,7 @@ export function WindowRenderer({ window, onClose }: WindowRendererProps) {
nip05Authors={window.props.nip05Authors}
nip05PTags={window.props.nip05PTags}
needsAccount={window.props.needsAccount}
needsInterestList={window.props.needsInterestList}
/>
);
break;

View File

@@ -9,13 +9,13 @@ import { Badge } from "@/components/ui/badge";
import { KindBadge } from "@/components/KindBadge";
import { SpellEvent } from "@/types/spell";
import { CopyableJsonViewer } from "@/components/JsonViewer";
import { User, Users } from "lucide-react";
import { User, Users, Hash } from "lucide-react";
import { cn } from "@/lib/utils";
import { UserName } from "../UserName";
import { useGrimoire } from "@/core/state";
import { useProfile } from "@/hooks/useProfile";
import { useNostrEvent } from "@/hooks/useNostrEvent";
import { getDisplayName } from "@/lib/nostr-utils";
import { getDisplayName, getAllTagValues } from "@/lib/nostr-utils";
/**
* Visual placeholder for $me
@@ -109,6 +109,61 @@ export function ContactsPlaceholder({
);
}
/**
* Visual placeholder for $hashtags
*/
export function HashtagsPlaceholder({
size = "sm",
className,
pubkey,
}: {
size?: "sm" | "md" | "lg";
className?: string;
pubkey?: string;
}) {
const { addWindow } = useGrimoire();
const interestList = useNostrEvent(
pubkey
? {
kind: 10015,
pubkey,
identifier: "",
}
: undefined,
);
const hashtags = interestList ? getAllTagValues(interestList, "t") : [];
const count = hashtags.length;
const label = count > 0 ? `${count} interests` : "$hashtags";
const handleClick = (e: React.MouseEvent) => {
if (!pubkey) return;
e.stopPropagation();
addWindow("open", {
pointer: {
kind: 10015,
pubkey,
identifier: "",
},
});
};
return (
<span
className={cn(
"inline-flex items-center gap-1.5 font-bold text-emerald-400 select-none",
pubkey && "cursor-crosshair hover:underline decoration-dotted",
size === "sm" ? "text-xs" : size === "md" ? "text-sm" : "text-lg",
className,
)}
onClick={handleClick}
>
<Hash className={cn(size === "sm" ? "size-3" : "size-4")} />
{label}
</span>
);
}
/**
* Renderer for a list of identifiers (pubkeys or placeholders)
*/
@@ -130,6 +185,10 @@ function IdentifierList({
return (
<ContactsPlaceholder key={val} size={size} pubkey={activePubkey} />
);
if (val === "$hashtags")
return (
<HashtagsPlaceholder key={val} size={size} pubkey={activePubkey} />
);
return (
<UserName
key={val}