From 698ae25ea3a2be42d65236ad1e6be2b36394f1f5 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Thu, 12 Jun 2025 17:44:36 +0300 Subject: [PATCH] fix blocked info at startup --- src/App.tsx | 2 +- src/hooks/useBlockUsers.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 381b41b..87d8b37 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -397,7 +397,7 @@ function App() { addToBlockList, removeBlockFromList, getAllBlockedUsers, - } = useBlockedAddresses(); + } = useBlockedAddresses(extState === 'authenticated'); const [currentNode, setCurrentNode] = useState({ url: 'http://127.0.0.1:12391', diff --git a/src/hooks/useBlockUsers.tsx b/src/hooks/useBlockUsers.tsx index 4aa100c..9e64e3b 100644 --- a/src/hooks/useBlockUsers.tsx +++ b/src/hooks/useBlockUsers.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useMemo, useRef } from 'react'; -export const useBlockedAddresses = () => { +export const useBlockedAddresses = (isAuthenticated?: boolean) => { const userBlockedRef = useRef({}); const userNamesBlockedRef = useRef({}); @@ -22,6 +22,9 @@ export const useBlockedAddresses = () => { }, []); useEffect(() => { + if (!isAuthenticated) return; + userBlockedRef.current = {}; + userNamesBlockedRef.current = {}; const fetchBlockedList = async () => { try { const response = await new Promise((res, rej) => { @@ -82,7 +85,7 @@ export const useBlockedAddresses = () => { } }; fetchBlockedList(); - }, []); + }, [isAuthenticated]); const removeBlockFromList = useCallback(async (address, name) => { if (name) {