Skip to content

Commit

Permalink
fix: APP-331 close PostFlow modal on sign tx success (#2465)
Browse files Browse the repository at this point in the history
  • Loading branch information
blushi authored Sep 10, 2024
1 parent c025948 commit 065adcc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const PostFlow = ({
projectId,
offChainProjectId,
projectName,
onModalClose,
});

useEffect(() => {
Expand Down Expand Up @@ -188,6 +189,7 @@ export const PostFlow = ({
projectId,
offChainProjectId,
projectName,
onModalClose,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ export type UseFetchMsgAnchorParams = {
projectName?: string;
projectSlug?: string | null;
offChainProjectId?: string;
onModalClose: () => void;
};

export const useFetchMsgAnchor = ({
projectSlug,
projectId,
offChainProjectId,
projectName,
onModalClose,
}: UseFetchMsgAnchorParams) => {
const { txClient } = useLedger();
const { _ } = useLingui();
Expand Down Expand Up @@ -97,11 +99,13 @@ export const useFetchMsgAnchor = ({
atom.buttonTitle = _(VIEW_POST);
atom.buttonLink = buttonLink;
});
onModalClose();
},
[
_,
getSuccessModalContent,
offChainProjectId,
onModalClose,
projectId,
projectName,
projectSlug,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const useSign = ({
projectId,
offChainProjectId,
projectName,
onModalClose,
}: UseSignParams) => {
const { _ } = useLingui();
const getSuccessModalContent = useGetSuccessModalContent();
Expand Down Expand Up @@ -110,6 +111,7 @@ export const useSign = ({
atom.buttonLink = buttonLink;
atom.txHash = undefined;
});
onModalClose();
},
onSuccess: async (deliverTxResponse?: DeliverTxResponse) => {
const { data: anchorTxsData } = await refetch();
Expand Down Expand Up @@ -147,6 +149,7 @@ export const useSign = ({
atom.buttonLink = buttonLink;
atom.txHash = undefined;
});
onModalClose();
},
},
);
Expand All @@ -155,6 +158,7 @@ export const useSign = ({
_,
getSuccessModalContent,
offChainProjectId,
onModalClose,
projectId,
projectName,
projectSlug,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useCallback, useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { useAtom } from 'jotai';

import { TxSuccessfulModal } from 'web-components/src/components/modal/TxSuccessfulModal';
Expand All @@ -8,15 +10,23 @@ import { getHashUrl } from 'lib/block-explorer';
import { Link } from 'components/atoms';

export const RegistryLayoutTxSuccessfulModal = (): JSX.Element => {
const location = useLocation();

const [
{ cardItems, title, cardTitle, open, txHash, buttonTitle, buttonLink },
setTxSuccessfulModalAtom,
] = useAtom(txSuccessfulModalAtom);
const onClose = (): void =>
setTxSuccessfulModalAtom(atom => void (atom.open = false));
const onClose = useCallback(
(): void => setTxSuccessfulModalAtom(atom => void (atom.open = false)),
[setTxSuccessfulModalAtom],
);

const txHashUrl = getHashUrl(txHash);

useEffect(() => {
onClose();
}, [location, onClose]);

return (
<TxSuccessfulModal
open={!!open}
Expand Down

0 comments on commit 065adcc

Please sign in to comment.