mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
Prevent double send actions in SendPage (#2542)
This commit is contained in:
@@ -64,6 +64,7 @@ class SendPage extends BasePage {
|
||||
final PaymentRequest? initialPaymentRequest;
|
||||
|
||||
bool _effectsInstalled = false;
|
||||
bool _sendInProgress = false;
|
||||
ContactRecord? newContactAddress;
|
||||
|
||||
@override
|
||||
@@ -412,6 +413,9 @@ class SendPage extends BasePage {
|
||||
return LoadingPrimaryButton(
|
||||
key: ValueKey('send_page_send_button_key'),
|
||||
onPressed: () async {
|
||||
// Prevent double taps
|
||||
if (_sendInProgress) return;
|
||||
|
||||
//Request dummy node to get the focus out of the text fields
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
|
||||
@@ -467,6 +471,8 @@ class SendPage extends BasePage {
|
||||
}
|
||||
}
|
||||
|
||||
_sendInProgress = true;
|
||||
|
||||
final check = sendViewModel.shouldDisplayTotp();
|
||||
authService.authenticateAction(
|
||||
context,
|
||||
@@ -474,6 +480,8 @@ class SendPage extends BasePage {
|
||||
onAuthSuccess: (value) async {
|
||||
if (value) {
|
||||
await sendViewModel.createTransaction();
|
||||
} else {
|
||||
_sendInProgress = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -522,6 +530,7 @@ class SendPage extends BasePage {
|
||||
}
|
||||
|
||||
if (state is FailureState) {
|
||||
_sendInProgress = false;
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) {
|
||||
showPopUp<void>(
|
||||
@@ -602,11 +611,13 @@ class SendPage extends BasePage {
|
||||
);
|
||||
|
||||
if (result == null) sendViewModel.dismissTransaction();
|
||||
_sendInProgress = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
_sendInProgress = false;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user