mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-10 07:27:23 +02:00
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:
@@ -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;
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user