Skip to content

Commit 91def42

Browse files
authored
fix: swap call oncancel error (#6404)
1 parent b5eb4ea commit 91def42

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/kit/src/views/Send/pages/SendConfirmFromSwap/SendConfirmFromSwap.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ function SendConfirmFromSwap() {
2525
const navigation = useNavigation();
2626
const appNavigation = useAppNavigation();
2727

28+
const navigationToNext = useRef(false);
29+
2830
const route =
2931
useRoute<
3032
RouteProp<IModalSendParamList, EModalSendRoutes.SendConfirmFromSwap>
@@ -68,25 +70,28 @@ function SendConfirmFromSwap() {
6870
const isLastTx = i === len - 1;
6971

7072
const result: ISendTxOnSuccessData[] = await new Promise((resolve) => {
73+
navigationToNext.current = true;
7174
appNavigation.push(EModalSendRoutes.SendConfirm, {
7275
...route.params,
7376
popStack: false,
7477
unsignedTxs: [unsignedTx],
7578
onSuccess: (data: ISendTxOnSuccessData[]) => {
79+
navigationToNext.current = false;
7680
if (isLastTx) {
77-
onSuccess?.(data);
7881
appNavigation.pop();
82+
onSuccess?.(data);
7983
}
8084
resolve(data);
8185
},
8286
onFail: (error: Error) => {
83-
onFail?.(error);
84-
87+
navigationToNext.current = false;
8588
appNavigation.pop();
89+
onFail?.(error);
8690
},
8791
onCancel: () => {
88-
onCancel?.();
92+
navigationToNext.current = false;
8993
appNavigation.pop();
94+
onCancel?.();
9095
},
9196
});
9297
});
@@ -136,6 +141,7 @@ function SendConfirmFromSwap() {
136141
}
137142

138143
if (!batchEstimateButSingleConfirm) {
144+
navigationToNext.current = true;
139145
action = StackActions.replace(EModalSendRoutes.SendConfirm, {
140146
...route.params,
141147
// @ts-ignore
@@ -160,7 +166,9 @@ function SendConfirmFromSwap() {
160166
]);
161167

162168
const handleOnClose = () => {
163-
onCancel?.();
169+
if (!navigationToNext.current) {
170+
onCancel?.();
171+
}
164172
};
165173

166174
useEffect(() => {

0 commit comments

Comments
 (0)