From c3fe727f84bb86d1d24dcfb9c3dfc0459992aab9 Mon Sep 17 00:00:00 2001 From: Bob <160986752+bob2402@users.noreply.github.com> Date: Sun, 8 Sep 2024 11:43:49 +0800 Subject: [PATCH] problem: incorrect tags when publishing event (#25) --- src/lib/views/messages/Messages.svelte | 37 +++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/lib/views/messages/Messages.svelte b/src/lib/views/messages/Messages.svelte index 68fbe1c..b7ef482 100644 --- a/src/lib/views/messages/Messages.svelte +++ b/src/lib/views/messages/Messages.svelte @@ -8,9 +8,9 @@ import { PushEvent, FrontendDataStore as feds, viewed } from '@/snort_workers/main'; import { updateRepliesInPlace } from '@/snort_workers/utils'; import { stableShortList, threadParentID, threadParentIDChain } from '@/stores/shortlist'; - import { NDKEvent } from '@nostr-dev-kit/ndk'; + import { NDKEvent, type NDKTag } from '@nostr-dev-kit/ndk'; import NDKSvelte from '@nostr-dev-kit/ndk-svelte'; - import { RequestBuilder, type QueryLike } from '@snort/system'; + import { RequestBuilder, type QueryLike, type Tag } from '@snort/system'; import { BloomFilter } from 'bloomfilter'; import type { NostrEvent } from 'nostr-tools'; import { onMount } from 'svelte'; @@ -20,7 +20,7 @@ import RenderKind1AsThreadHead from './RenderKind1AsThreadHead.svelte'; import { System } from './snort'; - let messageInputContent = "" + let messageInputContent = ''; let localEvents = writable(new Map()); @@ -186,6 +186,28 @@ window.visualViewport?.removeEventListener('resize', handleResize); }; }); + + $: tags = () => { + const tags: NDKTag[] = []; + if ($threadParentID !== 'root') { + const path = $threadParentIDChain; + if (path.length >= 2) { + tags.push(['p', $FrontendDataStore.events.get($threadParentID)?.pubkey!]); + tags.push(['e', path[1], '', 'root']); + if (path.length === 2) { + tags.push(['e', path[1], '', 'reply']); + } else { + tags.push(['e', path[path.length - 1], '', 'reply']); + if (path.length > 3) { + for (let i = 2; i < path.length - 1; i++) { + tags.push(['e', path[i], '', 'mention']); + } + } + } + } + } + return tags; + }; @@ -200,7 +222,8 @@ {#if $threadParentID != 'root'} {/if} - {#each $stableShortList as event, i (event.id)} {/if} -
+
+ +

HUMBLE HORSE

@@ -298,7 +323,7 @@ >

Your Keyword Ranks

-
+
{#each [...$FrontendDataStore.keywords].sort(([sa, a], [sb, b]) => { return b - a; }) as [word, count]}{word}: {count}
{/each}