mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 09:29:48 +00:00
Fix Contact page reaction excuted more than once (#1467)
This commit is contained in:
parent
8c1206ea04
commit
058522caf1
1 changed files with 20 additions and 9 deletions
|
@ -46,6 +46,7 @@ class ContactPage extends BasePage {
|
||||||
final TextEditingController _nameController;
|
final TextEditingController _nameController;
|
||||||
final TextEditingController _currencyTypeController;
|
final TextEditingController _currencyTypeController;
|
||||||
final TextEditingController _addressController;
|
final TextEditingController _addressController;
|
||||||
|
bool _isEffectsApplied = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
|
@ -53,15 +54,7 @@ class ContactPage extends BasePage {
|
||||||
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
|
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
|
||||||
height: 8);
|
height: 8);
|
||||||
|
|
||||||
reaction((_) => contactViewModel.state, (ExecutionState state) {
|
_setEffects(context);
|
||||||
if (state is FailureState) {
|
|
||||||
_onContactSavingFailure(context, state.error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state is ExecutedSuccessfullyState) {
|
|
||||||
_onContactSavedSuccessfully(context);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return Observer(
|
return Observer(
|
||||||
builder: (_) => ScrollableWithBottomSection(
|
builder: (_) => ScrollableWithBottomSection(
|
||||||
|
@ -177,4 +170,22 @@ class ContactPage extends BasePage {
|
||||||
|
|
||||||
void _onContactSavedSuccessfully(BuildContext context) =>
|
void _onContactSavedSuccessfully(BuildContext context) =>
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
|
void _setEffects(BuildContext context) {
|
||||||
|
if (_isEffectsApplied) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isEffectsApplied = true;
|
||||||
|
|
||||||
|
reaction((_) => contactViewModel.state, (ExecutionState state) {
|
||||||
|
if (state is FailureState) {
|
||||||
|
_onContactSavingFailure(context, state.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state is ExecutedSuccessfullyState) {
|
||||||
|
_onContactSavedSuccessfully(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue