From 114b3a035b1e8b001743a45e4b541990db68dfae Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Tue, 29 Jul 2025 14:14:05 -0500 Subject: [PATCH] Simplify link generation in `PublicationHeader` component The component only needs to work with kind 30040 index events. --- .../publications/PublicationHeader.svelte | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib/components/publications/PublicationHeader.svelte b/src/lib/components/publications/PublicationHeader.svelte index 20a61a3..c293fc9 100644 --- a/src/lib/components/publications/PublicationHeader.svelte +++ b/src/lib/components/publications/PublicationHeader.svelte @@ -7,6 +7,7 @@ import { userBadge } from "$lib/snippets/UserSnippets.svelte"; import LazyImage from "$components/util/LazyImage.svelte"; import { generateDarkPastelColor } from "$lib/utils/image_utils"; + import { indexKind } from "$lib/consts"; const { event } = $props<{ event: NDKEvent }>(); @@ -19,20 +20,16 @@ }); const href = $derived.by(() => { - const d = event.getMatchingTags("d")[0]?.[1]; - const isReplaceableEvent = event.kind === 30040 || event.kind === 30041; + const dTag = event.getMatchingTags("d")[0]?.[1]; + const isIndexEvent = event.kind === indexKind; - if (d != null && isReplaceableEvent) { - // For replaceable events with d tag, use naddr encoding + if (dTag != null && isIndexEvent) { + // For index events with d tag, use naddr encoding const naddr = naddrEncode(event, relays); return `publication/naddr/${naddr}`; - } else if (event.id) { - // For non-replaceable events or events without d tag, use nevent encoding - const nevent = neventEncode(event, relays); - return `publication/nevent/${nevent}`; } else { // Fallback to d tag if available - return d ? `publication/d/${d}` : null; + return dTag ? `publication/d/${dTag}` : null; } });