From 9c29dbd6fd7823e4deb5da871b752087ca8ef06f Mon Sep 17 00:00:00 2001 From: Serhii Date: Sat, 10 Aug 2024 01:18:55 +0300 Subject: [PATCH] fix zero initial fee rates in RBF rate picker (#1585) * fix zero initial fee rates in RBF rate picker * fix for other settings page[skip ci] --- lib/di.dart | 4 ++-- lib/src/screens/settings/other_settings_page.dart | 7 ++++++- .../transaction_details/transaction_details_page.dart | 7 ++++++- lib/src/widgets/picker.dart | 4 ++-- lib/view_model/settings/other_settings_view_model.dart | 4 +++- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index a37574f21..a64270f6d 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -759,8 +759,8 @@ Future setup({ getIt.registerFactory(() => TrocadorProvidersViewModel(getIt.get())); getIt.registerFactory(() { - return OtherSettingsViewModel(getIt.get(), getIt.get().wallet!); - }); + return OtherSettingsViewModel(getIt.get(), getIt.get().wallet!, + getIt.get());}); getIt.registerFactory(() { return SecuritySettingsViewModel(getIt.get()); diff --git a/lib/src/screens/settings/other_settings_page.dart b/lib/src/screens/settings/other_settings_page.dart index 9bba51944..137f699f5 100644 --- a/lib/src/screens/settings/other_settings_page.dart +++ b/lib/src/screens/settings/other_settings_page.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/bitcoin/bitcoin.dart'; import 'package:cake_wallet/entities/priority_for_wallet_type.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; @@ -12,7 +13,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; class OtherSettingsPage extends BasePage { - OtherSettingsPage(this._otherSettingsViewModel); + OtherSettingsPage(this._otherSettingsViewModel) { + if (_otherSettingsViewModel.sendViewModel.isElectrumWallet) { + bitcoin!.updateFeeRates(_otherSettingsViewModel.sendViewModel.wallet); + } + } @override String get title => S.current.other_settings; diff --git a/lib/src/screens/transaction_details/transaction_details_page.dart b/lib/src/screens/transaction_details/transaction_details_page.dart index 7734f37ed..d06b935dd 100644 --- a/lib/src/screens/transaction_details/transaction_details_page.dart +++ b/lib/src/screens/transaction_details/transaction_details_page.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/bitcoin/bitcoin.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; @@ -15,7 +16,11 @@ import 'package:flutter/services.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; class TransactionDetailsPage extends BasePage { - TransactionDetailsPage({required this.transactionDetailsViewModel}); + TransactionDetailsPage({required this.transactionDetailsViewModel}) { + if (transactionDetailsViewModel.sendViewModel.isElectrumWallet) { + bitcoin!.updateFeeRates(transactionDetailsViewModel.sendViewModel.wallet); + } + } @override String get title => S.current.transaction_details_title; diff --git a/lib/src/widgets/picker.dart b/lib/src/widgets/picker.dart index b744d1db0..a7cb03a4e 100644 --- a/lib/src/widgets/picker.dart +++ b/lib/src/widgets/picker.dart @@ -499,10 +499,10 @@ class _PickerState extends State> { children: [ Expanded( child: Slider( - value: widget.sliderValue ?? 1, + value: widget.sliderValue == null || widget.sliderValue! < 1 ? 1 : widget.sliderValue!, onChanged: isActivated ? widget.onSliderChanged : null, min: widget.minValue ?? 1, - max: widget.maxValue ?? 100, + max: (widget.maxValue == null || widget.maxValue! < 1) ? 100 : widget.maxValue!, divisions: 100, ), ), diff --git a/lib/view_model/settings/other_settings_view_model.dart b/lib/view_model/settings/other_settings_view_model.dart index bd04755fa..9af8c67cf 100644 --- a/lib/view_model/settings/other_settings_view_model.dart +++ b/lib/view_model/settings/other_settings_view_model.dart @@ -4,6 +4,7 @@ import 'package:cake_wallet/entities/provider_types.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/utils/package_info.dart'; +import 'package:cake_wallet/view_model/send/send_view_model.dart'; // import 'package:package_info/package_info.dart'; import 'package:collection/collection.dart'; import 'package:cw_core/balance.dart'; @@ -20,7 +21,7 @@ class OtherSettingsViewModel = OtherSettingsViewModelBase with _$OtherSettingsViewModel; abstract class OtherSettingsViewModelBase with Store { - OtherSettingsViewModelBase(this._settingsStore, this._wallet) + OtherSettingsViewModelBase(this._settingsStore, this._wallet, this.sendViewModel) : walletType = _wallet.type, currentVersion = '' { PackageInfo.fromPlatform().then( @@ -42,6 +43,7 @@ abstract class OtherSettingsViewModelBase with Store { String currentVersion; final SettingsStore _settingsStore; + final SendViewModel sendViewModel; @computed TransactionPriority get transactionPriority {