Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Donation Modal after address switching and network modal is not flickering #4812

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/modals/DonateWrongNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const DonateWrongNetwork: FC<IDonateWrongNetwork> = props => {
const router = useRouter();
const { switchChain } = useSwitchChain();
const isSafeEnv = useIsSafeEnvironment();
const { setDonateModalByPriority } = useDonateData();
const { setDonateModalByPriority, currentDonateModal } = useDonateData();
const closeNetworkModal = useCallback(() => {
setDonateModalByPriority(DonateModalPriorityValues.None);
closeModal();
Expand Down Expand Up @@ -95,7 +95,7 @@ export const DonateWrongNetwork: FC<IDonateWrongNetwork> = props => {
) {
closeNetworkModal();
}
}, [networkId, acceptedChains]);
}, [networkId, acceptedChains, currentDonateModal]);

return (
<Modal
Expand Down
7 changes: 5 additions & 2 deletions src/components/views/donate/DonateIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const DonateIndex: FC = () => {
qrDonationStatus,
draftDonationData,
hasActiveQFRound,
currentDonateModal,
shouldRenderModal,
setSuccessDonation,
setQRDonationStatus,
Expand Down Expand Up @@ -122,7 +123,7 @@ const DonateIndex: FC = () => {

useEffect(() => {
validateSanctions();
}, [project, address]);
}, [project, address, currentDonateModal]);

useEffect(() => {
if (
Expand All @@ -132,11 +133,13 @@ const DonateIndex: FC = () => {
setDonateModalByPriority(
DonateModalPriorityValues.DonationByProjectOwner,
);
} else {
setDonateModalByPriority(DonateModalPriorityValues.None);
}
setIsModalPriorityChecked(
DonateModalPriorityValues.DonationByProjectOwner,
);
}, [userData?.id, project.adminUser]);
}, [userData?.id, project.adminUser, currentDonateModal]);

useEffect(() => {
const fetchDonation = async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/context/donate.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface IDonateContext {
project: IProject;
successDonation?: ISuccessDonation;
tokenStreams: ITokenStreams;
currentDonateModal: DonateModalPriorityValues;
setSuccessDonation: (successDonation?: ISuccessDonation) => void;
selectedOneTimeToken?: IProjectAcceptedToken;
selectedRecurringToken?: ISelectTokenWithBalance;
Expand Down Expand Up @@ -82,6 +83,7 @@ const DonateContext = createContext<IDonateContext>({
setSuccessDonation: () => {},
setSelectedOneTimeToken: () => {},
setSelectedRecurringToken: () => {},
currentDonateModal: DonateModalPriorityValues.None,
project: {} as IProject,
tokenStreams: {},
fetchProject: async () => {},
Expand Down Expand Up @@ -244,6 +246,7 @@ export const DonateProvider: FC<IProviderProps> = ({ children, project }) => {
setSelectedRecurringToken,
setIsModalPriorityChecked,
tokenStreams,
currentDonateModal,
fetchProject,
draftDonationData: draftDonation as IDraftDonation,
setDraftDonationData: setDraftDonation,
Expand Down
Loading