From 5adc033554fcbaf6c84fa91ef109ee6012c4d686 Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Tue, 10 Dec 2024 19:58:50 -0500 Subject: [PATCH] Update useHatsTree hook to accept safeAddress parameter and adjust resetStore conditional to just reset store when safeAddress changes --- src/hooks/DAO/loaders/useHatsTree.ts | 6 +++--- src/pages/dao/SafeController.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hooks/DAO/loaders/useHatsTree.ts b/src/hooks/DAO/loaders/useHatsTree.ts index b6b181c97..693824e08 100644 --- a/src/hooks/DAO/loaders/useHatsTree.ts +++ b/src/hooks/DAO/loaders/useHatsTree.ts @@ -19,7 +19,7 @@ import { getValue, setValue } from '../../utils/cache/useLocalStorage'; const hatsSubgraphClient = new HatsSubgraphClient({}); -const useHatsTree = () => { +const useHatsTree = ({ safeAddress }: { safeAddress: Address | undefined }) => { const { t } = useTranslation('roles'); const { governanceContracts: { @@ -293,10 +293,10 @@ const useHatsTree = () => { }, [hatsTree, updateRolesWithStreams, getPaymentStreams, streamsFetched]); useEffect(() => { - if (!hatsTreeId && !!hatsTree) { + if (safeAddress === undefined) { resetHatsStore(); } - }, [resetHatsStore, hatsTree, hatsTreeId]); + }, [resetHatsStore, safeAddress]); }; export { useHatsTree }; diff --git a/src/pages/dao/SafeController.tsx b/src/pages/dao/SafeController.tsx index 2f3c92f68..6b6ac3c99 100644 --- a/src/pages/dao/SafeController.tsx +++ b/src/pages/dao/SafeController.tsx @@ -43,7 +43,7 @@ export function SafeController() { useAzoriusListeners(); useKeyValuePairs(); - useHatsTree(); + useHatsTree({ safeAddress }); // the order of the if blocks of these next three error states matters if (invalidQuery) {