diff --git a/src/lib/components/EventDetails.svelte b/src/lib/components/EventDetails.svelte index fcec179..da9e84a 100644 --- a/src/lib/components/EventDetails.svelte +++ b/src/lib/components/EventDetails.svelte @@ -10,6 +10,7 @@ import ProfileHeader from "$components/cards/ProfileHeader.svelte"; import { getUserMetadata } from "$lib/utils/nostrUtils"; import CopyToClipboard from '$lib/components/util/CopyToClipboard.svelte'; + import { goto } from '$app/navigation'; const { event, profile = null, searchValue = null } = $props<{ event: NDKEvent; @@ -48,15 +49,17 @@ return MTag[1].split('/')[1] || `Event Kind ${event.kind}`; } - function renderTag(tag: string[]): string { + function getTagButtonInfo(tag: string[]): { text: string, gotoValue?: string } { if (tag[0] === 'a' && tag.length > 1) { const [kind, pubkey, d] = tag[1].split(':'); - return `a:${tag[1]}`; - } else if (tag[0] === 'e' && tag.length > 1) { - return `e:${tag[1]}`; - } else { - return `${tag[0]}:${tag[1]}`; + const naddr = naddrEncode({kind: +kind, pubkey, tags: [['d', d]], content: '', id: '', sig: ''} as any, standardRelays); + return { text: `a:${tag[1]}`, gotoValue: naddr }; + } + if (tag[0] === 'e' && tag.length > 1) { + const nevent = neventEncode({id: tag[1], kind: 1, content: '', tags: [], pubkey: '', sig: ''} as any, standardRelays); + return { text: `e:${tag[1]}`, gotoValue: nevent }; } + return { text: '' }; } $effect(() => { @@ -180,7 +183,15 @@ Event Tags:
{#each event.tags as tag} - {@html renderTag(tag)} + {@const tagInfo = getTagButtonInfo(tag)} + {#if tagInfo.text && tagInfo.gotoValue} + + {/if} {/each}
diff --git a/src/routes/events/+page.svelte b/src/routes/events/+page.svelte index b43b07a..9b575ca 100644 --- a/src/routes/events/+page.svelte +++ b/src/routes/events/+page.svelte @@ -38,12 +38,14 @@ } } - onMount(async () => { + $effect(() => { const id = $page.url.searchParams.get('id'); - if (id) { + if (id !== searchValue) { searchValue = id; } + }); + onMount(async () => { // Get user's pubkey and relay preference from localStorage userPubkey = localStorage.getItem('userPubkey'); userRelayPreference = localStorage.getItem('useUserRelays') === 'true';