Skip to content

Commit

Permalink
Reset Safe state when daoAddress is goes null
Browse files Browse the repository at this point in the history
  • Loading branch information
DarksightKellar committed Aug 2, 2024
1 parent eda21d9 commit f1d189a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
16 changes: 15 additions & 1 deletion src/pages/DAOController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { toast } from 'react-toastify';
import useDAOController from '../hooks/DAO/useDAOController';
import { useUpdateSafeData } from '../hooks/utils/useUpdateSafeData';
import { useFractal } from '../providers/App/AppProvider';
import { useRolesState } from '../state/useRolesState';
import LoadingProblem from './LoadingProblem';

const useTemporaryProposals = () => {
Expand Down Expand Up @@ -33,9 +34,12 @@ const useTemporaryProposals = () => {

export default function DAOController() {
const { errorLoading, wrongNetwork, invalidQuery } = useDAOController();
const { resetHatsStore } = useRolesState();

useUpdateSafeData();
const {
node: { daoName },
node: { daoName, daoAddress },
action,
} = useFractal();

useTemporaryProposals();
Expand All @@ -50,6 +54,16 @@ export default function DAOController() {
};
}, [daoName]);

// Reset Safe state when daoAddress is goes null
useEffect(() => {
console.log({daoAddress});

if (!daoAddress) {
action.resetSafeState();
resetHatsStore();
}
} ,[action, resetHatsStore, daoName, daoAddress]);

let display;

// the order of the if blocks of these next three error states matters
Expand Down
16 changes: 0 additions & 16 deletions src/pages/home/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
import { Flex, Button, Text, Spacer, Hide } from '@chakra-ui/react';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { DecentSignature } from '../../assets/theme/custom/icons/DecentSignature';
import { BASE_ROUTES } from '../../constants/routes';
import { useFractal } from '../../providers/App/AppProvider';
import { useRolesState } from '../../state/useRolesState';
import { MySafes } from './MySafes';

export default function HomePage() {
const {
node: { daoAddress },
action,
} = useFractal();

const { t } = useTranslation('home');
const { resetHatsStore } = useRolesState();

useEffect(() => {
if (daoAddress) {
action.resetSafeState();
resetHatsStore();
}
}, [daoAddress, action, resetHatsStore]);

return (
<Flex
Expand Down

0 comments on commit f1d189a

Please sign in to comment.