diff --git a/src/lib/components/CommentBox.svelte b/src/lib/components/CommentBox.svelte
index eacb2de..c412cb8 100644
--- a/src/lib/components/CommentBox.svelte
+++ b/src/lib/components/CommentBox.svelte
@@ -4,7 +4,7 @@
import { nip19 } from "nostr-tools";
import { toNpub, getUserMetadata } from "$lib/utils/nostrUtils";
import { searchProfiles } from "$lib/utils/search_utility";
- import type { NostrProfile } from "$lib/utils/search_utility";
+ import type { NostrProfile, ProfileSearchResult } from "$lib/utils/search_utility";
import { userPubkey } from '$lib/stores/authStore.Svelte';
import type { NDKEvent } from "$lib/utils/nostrUtils";
@@ -16,12 +16,6 @@
publishEvent,
navigateToEvent,
} from "$lib/utils/nostrEventService";
- import { get } from 'svelte/store';
- import { ndkInstance } from '$lib/ndk';
- import type NDK from '@nostr-dev-kit/ndk';
- import { NDKRelaySet } from '@nostr-dev-kit/ndk';
- import { NDKRelay } from '@nostr-dev-kit/ndk';
- import { communityRelay } from '$lib/consts';
import { tick } from 'svelte';
import { goto } from "$app/navigation";
@@ -263,14 +257,25 @@
return;
}
+ console.log('Starting search for:', mentionSearch.trim());
+
// Set loading state
mentionLoading = true;
isSearching = true;
try {
+ console.log('Search promise created, waiting for result...');
const result = await searchProfiles(mentionSearch.trim());
+ console.log('Search completed, found profiles:', result.profiles.length);
+ console.log('Profile details:', result.profiles);
+ console.log('Community status:', result.Status);
+
+ // Update state
mentionResults = result.profiles;
communityStatus = result.Status;
+
+ console.log('State updated - mentionResults length:', mentionResults.length);
+ console.log('State updated - communityStatus keys:', Object.keys(communityStatus));
} catch (error) {
console.error('Error searching mentions:', error);
mentionResults = [];
@@ -278,6 +283,7 @@
} finally {
mentionLoading = false;
isSearching = false;
+ console.log('Search finished - loading:', mentionLoading, 'searching:', isSearching);
}
}
@@ -383,6 +389,7 @@
{#if mentionLoading}
Searching...
{:else if mentionResults.length > 0}
+ Found {mentionResults.length} results
{#each mentionResults as profile}
diff --git a/src/lib/components/EventDetails.svelte b/src/lib/components/EventDetails.svelte
index 03ddd2e..57e7440 100644
--- a/src/lib/components/EventDetails.svelte
+++ b/src/lib/components/EventDetails.svelte
@@ -13,6 +13,7 @@
import { getUserMetadata } from "$lib/utils/nostrUtils";
import CopyToClipboard from "$lib/components/util/CopyToClipboard.svelte";
import { navigateToEvent } from "$lib/utils/nostrEventService";
+ import ContainingIndexes from "$lib/components/util/ContainingIndexes.svelte";
const {
event,
@@ -86,10 +87,81 @@
function renderTag(tag: string[]): string {
if (tag[0] === 'a' && tag.length > 1) {
- const [kind, pubkey, d] = tag[1].split(':');
- return `a:${tag[1]}`;
+ const parts = tag[1].split(':');
+ if (parts.length >= 3) {
+ const [kind, pubkey, d] = parts;
+ // Validate that pubkey is a valid hex string
+ if (pubkey && /^[0-9a-fA-F]{64}$/.test(pubkey)) {
+ try {
+ const mockEvent = {
+ kind: +kind,
+ pubkey,
+ tags: [['d', d]],
+ content: '',
+ id: '',
+ sig: ''
+ } as any;
+ const naddr = naddrEncode(mockEvent, standardRelays);
+ return `a:${tag[1]}`;
+ } catch (error) {
+ console.warn('Failed to encode naddr for a tag in renderTag:', tag[1], error);
+ return `a:${tag[1]}`;
+ }
+ } else {
+ console.warn('Invalid pubkey in a tag in renderTag:', pubkey);
+ return `a:${tag[1]}`;
+ }
+ } else {
+ console.warn('Invalid a tag format in renderTag:', tag[1]);
+ return `a:${tag[1]}`;
+ }
} else if (tag[0] === 'e' && tag.length > 1) {
- return `e:${tag[1]}`;
+ // Validate that event ID is a valid hex string
+ if (/^[0-9a-fA-F]{64}$/.test(tag[1])) {
+ try {
+ const mockEvent = {
+ id: tag[1],
+ kind: 1,
+ content: '',
+ tags: [],
+ pubkey: '',
+ sig: ''
+ } as any;
+ const nevent = neventEncode(mockEvent, standardRelays);
+ return `e:${tag[1]}`;
+ } catch (error) {
+ console.warn('Failed to encode nevent for e tag in renderTag:', tag[1], error);
+ return `e:${tag[1]}`;
+ }
+ } else {
+ console.warn('Invalid event ID in e tag in renderTag:', tag[1]);
+ return `e:${tag[1]}`;
+ }
+ } else if (tag[0] === 'note' && tag.length > 1) {
+ // 'note' tags are the same as 'e' tags but with different prefix
+ if (/^[0-9a-fA-F]{64}$/.test(tag[1])) {
+ try {
+ const mockEvent = {
+ id: tag[1],
+ kind: 1,
+ content: '',
+ tags: [],
+ pubkey: '',
+ sig: ''
+ } as any;
+ const nevent = neventEncode(mockEvent, standardRelays);
+ return `note:${tag[1]}`;
+ } catch (error) {
+ console.warn('Failed to encode nevent for note tag in renderTag:', tag[1], error);
+ return `note:${tag[1]}`;
+ }
+ } else {
+ console.warn('Invalid event ID in note tag in renderTag:', tag[1]);
+ return `note:${tag[1]}`;
+ }
+ } else if (tag[0] === 'd' && tag.length > 1) {
+ // 'd' tags are used for identifiers in addressable events
+ return `d:${tag[1]}`;
} else {
return `${tag[0]}:${tag[1]}`;
}
@@ -100,21 +172,104 @@
gotoValue?: string;
} {
if (tag[0] === 'a' && tag.length > 1) {
- const [kind, pubkey, d] = tag[1].split(':');
- return {
- text: `a:${tag[1]}`,
- gotoValue: naddrEncode({kind: +kind, pubkey, tags: [['d', d]], content: '', id: '', sig: ''} as any, standardRelays)
- };
+ const parts = tag[1].split(':');
+ if (parts.length >= 3) {
+ const [kind, pubkey, d] = parts;
+ // Validate that pubkey is a valid hex string
+ if (pubkey && /^[0-9a-fA-F]{64}$/.test(pubkey)) {
+ try {
+ const mockEvent = {
+ kind: +kind,
+ pubkey,
+ tags: [['d', d]],
+ content: '',
+ id: '',
+ sig: ''
+ } as any;
+ const naddr = naddrEncode(mockEvent, standardRelays);
+ return {
+ text: `a:${tag[1]}`,
+ gotoValue: naddr
+ };
+ } catch (error) {
+ console.warn('Failed to encode naddr for a tag:', tag[1], error);
+ return { text: `a:${tag[1]}` };
+ }
+ } else {
+ console.warn('Invalid pubkey in a tag:', pubkey);
+ return { text: `a:${tag[1]}` };
+ }
+ } else {
+ console.warn('Invalid a tag format:', tag[1]);
+ return { text: `a:${tag[1]}` };
+ }
} else if (tag[0] === 'e' && tag.length > 1) {
- return {
- text: `e:${tag[1]}`,
- gotoValue: neventEncode({id: tag[1], kind: 1, content: '', tags: [], pubkey: '', sig: ''} as any, standardRelays)
- };
+ // Validate that event ID is a valid hex string
+ if (/^[0-9a-fA-F]{64}$/.test(tag[1])) {
+ try {
+ const mockEvent = {
+ id: tag[1],
+ kind: 1,
+ content: '',
+ tags: [],
+ pubkey: '',
+ sig: ''
+ } as any;
+ const nevent = neventEncode(mockEvent, standardRelays);
+ return {
+ text: `e:${tag[1]}`,
+ gotoValue: nevent
+ };
+ } catch (error) {
+ console.warn('Failed to encode nevent for e tag:', tag[1], error);
+ return { text: `e:${tag[1]}` };
+ }
+ } else {
+ console.warn('Invalid event ID in e tag:', tag[1]);
+ return { text: `e:${tag[1]}` };
+ }
} else if (tag[0] === 'p' && tag.length > 1) {
const npub = toNpub(tag[1]);
return {
text: `p:${npub || tag[1]}`,
- gotoValue: npub ? `/events?id=${npub}` : undefined
+ gotoValue: npub ? npub : undefined
+ };
+ } else if (tag[0] === 'note' && tag.length > 1) {
+ // 'note' tags are the same as 'e' tags but with different prefix
+ if (/^[0-9a-fA-F]{64}$/.test(tag[1])) {
+ try {
+ const mockEvent = {
+ id: tag[1],
+ kind: 1,
+ content: '',
+ tags: [],
+ pubkey: '',
+ sig: ''
+ } as any;
+ const nevent = neventEncode(mockEvent, standardRelays);
+ return {
+ text: `note:${tag[1]}`,
+ gotoValue: nevent
+ };
+ } catch (error) {
+ console.warn('Failed to encode nevent for note tag:', tag[1], error);
+ return { text: `note:${tag[1]}` };
+ }
+ } else {
+ console.warn('Invalid event ID in note tag:', tag[1]);
+ return { text: `note:${tag[1]}` };
+ }
+ } else if (tag[0] === 'd' && tag.length > 1) {
+ // 'd' tags are used for identifiers in addressable events
+ return {
+ text: `d:${tag[1]}`,
+ gotoValue: `d:${tag[1]}`
+ };
+ } else if (tag[0] === 't' && tag.length > 1) {
+ // 't' tags are hashtags - navigate to t-tag search
+ return {
+ text: `t:${tag[1]}`,
+ gotoValue: `t:${tag[1]}`
};
}
return { text: `${tag[0]}:${tag[1]}` };
@@ -246,15 +401,19 @@
Tags:
{#each getEventHashtags(event) as tag}
- #{tag} goto(`/events?t=${encodeURIComponent(tag)}`)}
+ class="px-2 py-1 rounded bg-primary-100 text-primary-800 text-sm font-medium hover:bg-primary-200 cursor-pointer"
+ >#{tag}
{/each}
{/if}
+
+
+
{#if event.kind !== 0}
@@ -289,8 +448,30 @@
{@const tagInfo = getTagButtonInfo(tag)}
{#if tagInfo.text && tagInfo.gotoValue}