fix: sync NIP-5C me parameter with active account on login/logout

Add useEffect to keep the me param field in sync with the active
account pubkey. Clears on logout, updates on account switch. Skips
updates while a scroll is actively running to avoid mid-execution changes.

Closes #265

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gómez
2026-04-15 14:49:10 +02:00
parent c4c6e781b3
commit 464812980d

View File

@@ -57,6 +57,19 @@ export function ScrollExecutor({ params, wasmBase64 }: ScrollExecutorProps) {
const isActive = runtimeState === "loading" || runtimeState === "running";
// Sync "me" param with active account pubkey
useEffect(() => {
const hasMeParam = params.some(
(p) => p.name === "me" && p.type === "public_key",
);
if (!hasMeParam || isActive) return;
setParamValues((prev) => ({
...prev,
me: pubkey || "",
}));
}, [pubkey, params, isActive]);
// Sorted, deduplicated display events (newest first)
const displayedEvents = useMemo(
() =>