add balance and tile update triggers
MODIFY
WalletWasabi.Fluent/Helpers/TileHelper.cs
WalletWasabi.Fluent/Helpers/TileHelper.cs
@@ -9,11 +9,11 @@ namespace WalletWasabi.Fluent.Helpers;
public static class TileHelper
{
- public static List<TileViewModel> GetNormalWalletTiles(WalletViewModel walletViewModel, IObservable<Unit> balanceChanged)
+ public static List<TileViewModel> GetNormalWalletTiles(WalletViewModel walletViewModel)
{
return new List<TileViewModel>
{
- new WalletBalanceTileViewModel(walletViewModel.Wallet, balanceChanged, walletViewModel.History.UnfilteredTransactions)
+ new WalletBalanceTileViewModel(walletViewModel.Wallet, walletViewModel.UiUpdateTriggers.BalanceUpdateTrigger, walletViewModel.History.UnfilteredTransactions)
{
TilePresets = new ObservableCollection<TilePresetViewModel>()
{
@@ -24,7 +24,7 @@ public static class TileHelper
TilePresetIndex = walletViewModel.LayoutIndex
},
- new PrivacyControlTileViewModel(walletViewModel, balanceChanged)
+ new PrivacyControlTileViewModel(walletViewModel, walletViewModel.UiUpdateTriggers.PrivacyProgressUpdateTrigger)
{
TilePresets = new ObservableCollection<TilePresetViewModel>()
{
@@ -48,11 +48,11 @@ public static class TileHelper
};
}
- public static List<TileViewModel> GetWatchOnlyWalletTiles(WalletViewModel walletViewModel, IObservable<Unit> balanceChanged)
+ public static List<TileViewModel> GetWatchOnlyWalletTiles(WalletViewModel walletViewModel)
{
return new List<TileViewModel>
{
- new WalletBalanceTileViewModel(walletViewModel.Wallet, balanceChanged, walletViewModel.History.UnfilteredTransactions)
+ new WalletBalanceTileViewModel(walletViewModel.Wallet, walletViewModel.UiUpdateTriggers.BalanceUpdateTrigger, walletViewModel.History.UnfilteredTransactions)
{
TilePresets = new ObservableCollection<TilePresetViewModel>()
{

MODIFY
WalletWasabi.Fluent/Models/UiUpdateTriggers.cs
WalletWasabi.Fluent/Models/UiUpdateTriggers.cs
@@ -27,4 +27,25 @@ public class UiUpdateTriggers
public IObservable<Unit> UsdExchangeRateChanged => _wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).ToSignal();
public IObservable<Unit> AnonScoreTargetChanged => _walletViewModel.CoinJoinSettings.WhenAnyValue(x => x.AnonScoreTarget).ToSignal().Throttle(TimeSpan.FromMilliseconds(3100));
+
+ public IObservable<Unit> TransactionHistoryUpdateTrigger =>
+ WalletRelevantTransactionProcessed
+ .Merge(PrivacyModeChanged)
+ .Throttle(TimeSpan.FromMilliseconds(100))
+ .ObserveOn(RxApp.MainThreadScheduler);
+
+ public IObservable<Unit> BalanceUpdateTrigger =>
+ WalletRelevantTransactionProcessed
+ .Merge(PrivacyModeChanged)
+ .Merge(UsdExchangeRateChanged)
+ .Throttle(TimeSpan.FromMilliseconds(100))
+ .ObserveOn(RxApp.MainThreadScheduler);
+
+ public IObservable<Unit> PrivacyProgressUpdateTrigger =>
+ WalletRelevantTransactionProcessed
+ .Merge(PrivacyModeChanged)
+ .Merge(AnonScoreTargetChanged)
+ .Throttle(TimeSpan.FromMilliseconds(100))
+ .ObserveOn(RxApp.MainThreadScheduler);
+
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
@@ -38,10 +38,10 @@ public partial class HistoryViewModel : ActivatableViewModel
[AutoNotify(SetterModifier = AccessModifier.Private)]
private bool _isTransactionHistoryLoaded;
- public HistoryViewModel(WalletViewModel walletViewModel, IObservable<Unit> updateTrigger)
+ public HistoryViewModel(WalletViewModel walletViewModel)
{
_walletViewModel = walletViewModel;
- _updateTrigger = updateTrigger;
+ _updateTrigger = _walletViewModel.UiUpdateTriggers.TransactionHistoryUpdateTrigger;
_transactionSourceList = new SourceList<HistoryItemViewModelBase>();
_transactions = new ObservableCollectionExtended<HistoryItemViewModelBase>();
_unfilteredTransactions = new ObservableCollectionExtended<HistoryItemViewModelBase>();

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
@@ -8,6 +8,7 @@ using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using WalletWasabi.Fluent.Helpers;
+using WalletWasabi.Fluent.Models;
using WalletWasabi.Fluent.ViewModels.Dialogs.Authorization;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Fluent.ViewModels.Wallets.Advanced;
@@ -51,22 +52,24 @@ public partial class WalletViewModel : WalletViewModelBase
Settings = new WalletSettingsViewModel(this);
CoinJoinSettings = new CoinJoinSettingsViewModel(this);
-
- var balanceChanged =
- Observable.FromEventPattern(
- Wallet.TransactionProcessor,
- nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed))
- .Select(_ => Unit.Default)
- .Merge(Observable.FromEventPattern(Wallet, nameof(Wallet.NewFilterProcessed)).Throttle(TimeSpan.FromSeconds(1)).Select(_ => Unit.Default))
- .Merge(Services.UiConfig.WhenAnyValue(x => x.PrivacyMode).Select(_ => Unit.Default))
- .Merge(Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Select(_ => Unit.Default))
- .Merge(CoinJoinSettings.WhenAnyValue(x => x.AnonScoreTarget).Select(_ => Unit.Default).Skip(1).Throttle(TimeSpan.FromMilliseconds(3000))
- .Throttle(TimeSpan.FromSeconds(0.1)))
- .ObserveOn(RxApp.MainThreadScheduler);
-
- History = new HistoryViewModel(this, balanceChanged);
-
- balanceChanged
+ UiUpdateTriggers = new UiUpdateTriggers(this);
+
+ // var balanceChanged =
+ // Observable.FromEventPattern(
+ // Wallet.TransactionProcessor,
+ // nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed))
+ // .Select(_ => Unit.Default)
+ // .Merge(Observable.FromEventPattern(Wallet, nameof(Wallet.NewFilterProcessed)).Throttle(TimeSpan.FromSeconds(1)).Select(_ => Unit.Default))
+ // .Merge(Services.UiConfig.WhenAnyValue(x => x.PrivacyMode).Select(_ => Unit.Default))
+ // .Merge(Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Select(_ => Unit.Default))
+ // .Merge(CoinJoinSettings.WhenAnyValue(x => x.AnonScoreTarget).Select(_ => Unit.Default).Skip(1).Throttle(TimeSpan.FromMilliseconds(3000))
+ // .Throttle(TimeSpan.FromSeconds(0.1)))
+ // .ObserveOn(RxApp.MainThreadScheduler);
+
+ History = new HistoryViewModel(this);
+
+ UiUpdateTriggers
+ .WalletRelevantTransactionProcessed
.Subscribe(_ => IsWalletBalanceZero = wallet.Coins.TotalAmount() == Money.Zero)
.DisposeWith(Disposables);
@@ -106,8 +109,8 @@ public partial class WalletViewModel : WalletViewModelBase
LayoutIndex = _normalLayoutIndex;
_tiles = wallet.KeyManager.IsWatchOnly
- ? TileHelper.GetWatchOnlyWalletTiles(this, balanceChanged)
- : TileHelper.GetNormalWalletTiles(this, balanceChanged);
+ ? TileHelper.GetWatchOnlyWalletTiles(this)
+ : TileHelper.GetNormalWalletTiles(this);
this.WhenAnyValue(x => x.LayoutIndex)
.Subscribe(x =>
@@ -167,6 +170,8 @@ public partial class WalletViewModel : WalletViewModelBase
CoinJoinStateViewModel = new CoinJoinStateViewModel(this, balanceChanged);
}
+ public UiUpdateTriggers UiUpdateTriggers { get; }
+
public CoinJoinSettingsViewModel CoinJoinSettings { get; }
public bool IsWatchOnly => Wallet.KeyManager.IsWatchOnly;

add balance and tile update triggers