From 624a43555fe6d0dad0a4d27b7b69f5134bc4691a Mon Sep 17 00:00:00 2001 From: PhilReact Date: Thu, 12 Jun 2025 17:44:22 +0300 Subject: [PATCH] fix blocked info at startup --- src/App.tsx | 2 +- src/components/Chat/useBlockUsers.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 23c0f97..9751fd3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -328,7 +328,7 @@ function App() { useState(""); const {isUserBlocked, addToBlockList, - removeBlockFromList, getAllBlockedUsers} = useBlockedAddresses() + removeBlockFromList, getAllBlockedUsers} = useBlockedAddresses(extState === 'authenticated') const [isOpenDrawerLookup, setIsOpenDrawerLookup] = useState(false) const [isMain, setIsMain] = useState( window?.location?.href?.includes("?main=true") diff --git a/src/components/Chat/useBlockUsers.tsx b/src/components/Chat/useBlockUsers.tsx index b787735..146347a 100644 --- a/src/components/Chat/useBlockUsers.tsx +++ b/src/components/Chat/useBlockUsers.tsx @@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useRef } from "react"; -export const useBlockedAddresses = () => { +export const useBlockedAddresses = (isAuthenticated: boolean) => { const userBlockedRef = useRef({}) const userNamesBlockedRef = useRef({}) @@ -28,6 +28,9 @@ export const useBlockedAddresses = () => { }, []) useEffect(()=> { + if (!isAuthenticated) return; + userBlockedRef.current = {}; + userNamesBlockedRef.current = {}; const fetchBlockedList = async ()=> { try { const response = await new Promise((res, rej) => { @@ -86,7 +89,7 @@ export const useBlockedAddresses = () => { } } fetchBlockedList() - }, []) + }, [isAuthenticated]) const removeBlockFromList = useCallback(async (address, name)=> { if(name){ await new Promise((res, rej) => {