Skip to content

Commit

Permalink
On Proposal creation page, refresh Safe Data to make sure we've got m…
Browse files Browse the repository at this point in the history
…ost recent nonce
  • Loading branch information
adamgall committed Apr 10, 2024
1 parent 2218084 commit 92a7b8a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/pages/daos/[daoAddress]/proposals/new/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Grid, GridItem, Box, Flex, Center } from '@chakra-ui/react';
import { Trash } from '@decent-org/fractal-ui';
import { Formik, FormikProps } from 'formik';
import { useState, useMemo } from 'react';
import { useState, useMemo, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { ProposalDetails } from '../../../../../components/ProposalCreate/ProposalDetails';
Expand All @@ -18,6 +18,8 @@ import useSubmitProposal from '../../../../../hooks/DAO/proposal/useSubmitPropos
import { useCreateProposalSchema } from '../../../../../hooks/schemas/proposalCreate/useCreateProposalSchema';
import { useCanUserCreateProposal } from '../../../../../hooks/utils/useCanUserSubmitProposal';
import { useFractal } from '../../../../../providers/App/AppProvider';
import { useSafeAPI } from '../../../../../providers/App/hooks/useSafeAPI';
import { NodeAction } from '../../../../../providers/App/node/action';
import { useNetworkConfig } from '../../../../../providers/NetworkConfig/NetworkConfigProvider';
import { CreateProposalForm, CreateProposalState, GovernanceType } from '../../../../../types';

Expand All @@ -27,9 +29,11 @@ const templateAreaSingleCol = `"content"

export default function ProposalCreatePage() {
const {
action,
node: { daoAddress, safe },
governance: { type },
} = useFractal();
const safeAPI = useSafeAPI();
const { addressPrefix } = useNetworkConfig();
const { createProposalValidation } = useCreateProposalSchema();
const { prepareProposal } = usePrepareProposal();
Expand All @@ -51,6 +55,20 @@ export default function ProposalCreatePage() {
}
};

useEffect(() => {
if (!safeAPI || !daoAddress) {
return;
}

(async () => {
const safeInfo = await safeAPI.getSafeData(daoAddress);
action.dispatch({
type: NodeAction.SET_SAFE_INFO,
payload: safeInfo,
});
})();
}, [action, daoAddress, safeAPI]);

if (!type || !daoAddress || !safe) {
return (
<Center minH={`calc(100vh - ${HEADER_HEIGHT})`}>
Expand Down

0 comments on commit 92a7b8a

Please sign in to comment.