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) {