Skip to content

Commit

Permalink
fix: swap call oncancel error (#6404)
Browse files Browse the repository at this point in the history
  • Loading branch information
weatherstar authored Dec 24, 2024
1 parent b5eb4ea commit 91def42
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ function SendConfirmFromSwap() {
const navigation = useNavigation();
const appNavigation = useAppNavigation();

const navigationToNext = useRef(false);

const route =
useRoute<
RouteProp<IModalSendParamList, EModalSendRoutes.SendConfirmFromSwap>
Expand Down Expand Up @@ -68,25 +70,28 @@ function SendConfirmFromSwap() {
const isLastTx = i === len - 1;

const result: ISendTxOnSuccessData[] = await new Promise((resolve) => {
navigationToNext.current = true;
appNavigation.push(EModalSendRoutes.SendConfirm, {
...route.params,
popStack: false,
unsignedTxs: [unsignedTx],
onSuccess: (data: ISendTxOnSuccessData[]) => {
navigationToNext.current = false;
if (isLastTx) {
onSuccess?.(data);
appNavigation.pop();
onSuccess?.(data);
}
resolve(data);
},
onFail: (error: Error) => {
onFail?.(error);

navigationToNext.current = false;
appNavigation.pop();
onFail?.(error);
},
onCancel: () => {
onCancel?.();
navigationToNext.current = false;
appNavigation.pop();
onCancel?.();
},
});
});
Expand Down Expand Up @@ -136,6 +141,7 @@ function SendConfirmFromSwap() {
}

if (!batchEstimateButSingleConfirm) {
navigationToNext.current = true;
action = StackActions.replace(EModalSendRoutes.SendConfirm, {
...route.params,
// @ts-ignore
Expand All @@ -160,7 +166,9 @@ function SendConfirmFromSwap() {
]);

const handleOnClose = () => {
onCancel?.();
if (!navigationToNext.current) {
onCancel?.();
}
};

useEffect(() => {
Expand Down

0 comments on commit 91def42

Please sign in to comment.