From 25272407a8cc570aff73fa3d3f24e49e186ba6e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 5 Jan 2026 17:48:05 +0000 Subject: [PATCH] refactor: use useMemo for $me resolution in ProfileViewer to match REQ pattern - Wrap resolvedPubkey calculation in useMemo with accountPubkey dependency - Ensures ProfileViewer properly re-renders when account changes - Matches the reactive pattern used in ReqViewer for alias resolution - Explicit dependency tracking makes reactivity more reliable --- src/components/ProfileViewer.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ProfileViewer.tsx b/src/components/ProfileViewer.tsx index 32d4e25..05130b3 100644 --- a/src/components/ProfileViewer.tsx +++ b/src/components/ProfileViewer.tsx @@ -27,7 +27,7 @@ import { useRelayState } from "@/hooks/useRelayState"; import { getConnectionIcon, getAuthIcon } from "@/lib/relay-status-utils"; import { addressLoader } from "@/services/loaders"; import { relayListCache } from "@/services/relay-list-cache"; -import { useEffect } from "react"; +import { useEffect, useMemo } from "react"; import type { Subscription } from "rxjs"; import { useGrimoire } from "@/core/state"; @@ -43,8 +43,11 @@ export function ProfileViewer({ pubkey }: ProfileViewerProps) { const { state } = useGrimoire(); const accountPubkey = state.activeAccount?.pubkey; - // Resolve $me alias - const resolvedPubkey = pubkey === "$me" ? accountPubkey : pubkey; + // Resolve $me alias (memoized to trigger updates when account changes) + const resolvedPubkey = useMemo( + () => (pubkey === "$me" ? accountPubkey : pubkey), + [pubkey, accountPubkey], + ); const profile = useProfile(resolvedPubkey); const eventStore = useEventStore();