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
This commit is contained in:
Claude
2026-01-05 17:48:05 +00:00
parent 84c91ea340
commit 25272407a8

View File

@@ -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();