mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-06 10:41:21 +02:00
fix: clickable spellbook link
This commit is contained in:
@@ -45,6 +45,8 @@ import { SPELLBOOK_KIND } from "@/constants/kinds";
|
|||||||
import { UserName } from "./nostr/UserName";
|
import { UserName } from "./nostr/UserName";
|
||||||
import { AGGREGATOR_RELAYS } from "@/services/loaders";
|
import { AGGREGATOR_RELAYS } from "@/services/loaders";
|
||||||
import { lastValueFrom } from "rxjs";
|
import { lastValueFrom } from "rxjs";
|
||||||
|
import { nip19 } from "nostr-tools";
|
||||||
|
import type { AddressPointer } from "nostr-tools/nip19";
|
||||||
|
|
||||||
interface SpellbookCardProps {
|
interface SpellbookCardProps {
|
||||||
spellbook: LocalSpellbook;
|
spellbook: LocalSpellbook;
|
||||||
@@ -63,7 +65,7 @@ function SpellbookCard({
|
|||||||
showAuthor = false,
|
showAuthor = false,
|
||||||
isOwner = true,
|
isOwner = true,
|
||||||
}: SpellbookCardProps) {
|
}: SpellbookCardProps) {
|
||||||
const { addWindow } = useGrimoire();
|
const { state, addWindow } = useGrimoire();
|
||||||
const [isPublishing, setIsPublishing] = useState(false);
|
const [isPublishing, setIsPublishing] = useState(false);
|
||||||
const [isDeleting, setIsDeleting] = useState(false);
|
const [isDeleting, setIsDeleting] = useState(false);
|
||||||
const displayName = spellbook.title || "Untitled Spellbook";
|
const displayName = spellbook.title || "Untitled Spellbook";
|
||||||
@@ -110,22 +112,22 @@ function SpellbookCard({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenEvent = () => {
|
const handleOpenEvent = () => {
|
||||||
const id = spellbook.eventId || (spellbook.event?.id as string);
|
if (spellbook.slug && authorPubkey) {
|
||||||
if (id && id.length === 64) {
|
// For addressable events (kind 30777)
|
||||||
addWindow("open", { pointer: { id } }, `open ${id}`);
|
const pointer: AddressPointer = {
|
||||||
} else if (spellbook.isPublished && spellbook.slug && authorPubkey) {
|
kind: SPELLBOOK_KIND,
|
||||||
// For addressable events (kind 30003)
|
pubkey: authorPubkey,
|
||||||
addWindow(
|
identifier: spellbook.slug,
|
||||||
"open",
|
relays: state.activeAccount?.relays?.map((r) => r.url) || [],
|
||||||
{
|
};
|
||||||
pointer: {
|
|
||||||
kind: SPELLBOOK_KIND,
|
const naddr = nip19.naddrEncode(pointer);
|
||||||
pubkey: authorPubkey,
|
addWindow("open", { pointer }, `open ${naddr}`);
|
||||||
identifier: spellbook.slug,
|
} else {
|
||||||
},
|
const id = spellbook.eventId || (spellbook.event?.id as string);
|
||||||
},
|
if (id && id.length === 64) {
|
||||||
`open ${SPELLBOOK_KIND}:${authorPubkey}:${spellbook.slug}`,
|
addWindow("open", { pointer: { id } }, `open ${id}`);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user