From 35623cfbf381f71c6476a077c5e78789a4b281a9 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Jan 2026 21:57:43 +0000 Subject: [PATCH] fix: fetch profile metadata for NIP-17 chat titles The getMetadata method was only checking the event store without actually fetching profiles from relays. Changed to use profileLoader which properly fetches kind 0 metadata from relays when not in store. This ensures chat titles show usernames instead of truncated pubkeys. --- src/lib/chat/adapters/nip-17-adapter.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/lib/chat/adapters/nip-17-adapter.ts b/src/lib/chat/adapters/nip-17-adapter.ts index 59979dc..165c333 100644 --- a/src/lib/chat/adapters/nip-17-adapter.ts +++ b/src/lib/chat/adapters/nip-17-adapter.ts @@ -21,7 +21,11 @@ import { isValidHexPubkey } from "@/lib/nostr-validation"; import { getProfileContent } from "applesauce-core/helpers"; import { getRelaysFromList } from "applesauce-common/helpers"; import { EventFactory } from "applesauce-core/event-factory"; -import { addressLoader, AGGREGATOR_RELAYS } from "@/services/loaders"; +import { + addressLoader, + profileLoader, + AGGREGATOR_RELAYS, +} from "@/services/loaders"; import { unlockGiftWrap, isGiftWrapUnlocked, @@ -728,11 +732,20 @@ export class Nip17Adapter extends ChatProtocolAdapter { } /** - * Helper: Get user metadata + * Helper: Get user metadata (fetches from relays if not in store) */ private async getMetadata(pubkey: string): Promise { - return firstValueFrom(eventStore.replaceable(0, pubkey), { - defaultValue: undefined, - }); + try { + // Use profileLoader to actually fetch the profile from relays + const event = await firstValueFrom( + profileLoader({ kind: 0, pubkey, identifier: "" }).pipe( + catchError(() => of(undefined)), + ), + { defaultValue: undefined }, + ); + return event ?? undefined; + } catch { + return undefined; + } } }