From 92eb50f8d2aa5232527d2db1271a14691b41fb41 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 20 Oct 2025 12:53:58 +0700 Subject: [PATCH] handle edge case cache reset when user changes relay while logged out then logs in again --- src/contexts/DMContext.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/contexts/DMContext.tsx b/src/contexts/DMContext.tsx index 6b46139..c30e107 100644 --- a/src/contexts/DMContext.tsx +++ b/src/contexts/DMContext.tsx @@ -1070,9 +1070,10 @@ export function DMProvider({ children, protocolMode = PROTOCOL_MODE.NIP17_ONLY, // Detect relay changes and reload messages useEffect(() => { - if (!enabled || !userPubkey || !hasInitialLoadCompleted) return; - if (previousRelayUrl.current !== config.relayUrl) { - previousRelayUrl.current = config.relayUrl; + const relayChanged = previousRelayUrl.current !== config.relayUrl; + previousRelayUrl.current = config.relayUrl; + + if (relayChanged && enabled && userPubkey && hasInitialLoadCompleted) { clearCacheAndReload(); } }, [enabled, userPubkey, config.relayUrl, hasInitialLoadCompleted, clearCacheAndReload]);