diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 53c52aa1e..998521ede 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -102,7 +102,9 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor outputs .add(Output(wallet, _settingsStore, _fiatConversationStore, () => selectedCryptoCurrency)); - unspentCoinsListViewModel.initialSetup(); + unspentCoinsListViewModel.initialSetup().then((_) { + unspentCoinsListViewModel.resetUnspentCoinsInfoSelections(); + }); } @observable @@ -728,11 +730,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor return S.current.insufficient_funds_for_tx; } - return - '''${S.current.insufficient_funds_for_tx} \n\n''' - '''${S.current.balance}: ${parsedErrorMessageResult.balanceEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.balanceUsd} ${fiatFromSettings.name})\n\n''' - '''${S.current.transaction_cost}: ${parsedErrorMessageResult.txCostEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.txCostUsd} ${fiatFromSettings.name})\n\n''' - '''${S.current.overshot}: ${parsedErrorMessageResult.overshotEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.overshotUsd} ${fiatFromSettings.name})'''; + return '''${S.current.insufficient_funds_for_tx} \n\n''' + '''${S.current.balance}: ${parsedErrorMessageResult.balanceEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.balanceUsd} ${fiatFromSettings.name})\n\n''' + '''${S.current.transaction_cost}: ${parsedErrorMessageResult.txCostEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.txCostUsd} ${fiatFromSettings.name})\n\n''' + '''${S.current.overshot}: ${parsedErrorMessageResult.overshotEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.overshotUsd} ${fiatFromSettings.name})'''; } return errorMessage; @@ -809,4 +810,4 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor return false; } -} \ No newline at end of file +} diff --git a/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart b/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart index 52820adcb..9a8a4a8f2 100644 --- a/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart +++ b/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart @@ -68,7 +68,6 @@ abstract class UnspentCoinsListViewModelBase with Store { bool get hasAdjustableFieldChanged => items.any(_hasAdjustableFieldChanged); - Future saveUnspentCoinInfo(UnspentCoinsItem item) async { try { final existingInfo = _unspentCoinsInfo.values @@ -79,7 +78,6 @@ abstract class UnspentCoinsListViewModelBase with Store { existingInfo.isSending = item.isSending; existingInfo.note = item.note; - await existingInfo.save(); _updateUnspentCoinsInfo(); } catch (e) { @@ -167,6 +165,17 @@ abstract class UnspentCoinsListViewModelBase with Store { items.addAll(unspents); } + @action + void resetUnspentCoinsInfoSelections() { + // reset all unspent coins selections to true except frozen ones + for (final item in items) { + if (!item.isFrozen) { + item.isSending = true; + saveUnspentCoinInfo(item); + } + } + } + @action void toggleSelectAll(bool value) { for (final item in items) {