use balanceChanged as a trigger
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
using System;
using System.Collections.ObjectModel;
+using System.Reactive;
+using System.Reactive.Concurrency;
+using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using DynamicData;
@@ -26,7 +29,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
[AutoNotify] private bool _showCoinJoin;
[AutoNotify] private HistoryItemViewModel? _selectedItem;
- public HistoryViewModel(Wallet wallet, UiConfig uiConfig)
+ public HistoryViewModel(Wallet wallet, UiConfig uiConfig, IObservable<Unit> updateTrigger)
{
_wallet = wallet;
_bitcoinStore = wallet.BitcoinStore;
@@ -56,7 +59,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
return;
}
- Navigate(NavigationTarget.DialogScreen).To(new TransactionDetailsViewModel(selectedItem.TransactionSummary, _bitcoinStore, wallet));
+ Navigate(NavigationTarget.DialogScreen).To(new TransactionDetailsViewModel(selectedItem.TransactionSummary, _bitcoinStore, wallet, updateTrigger));
});
this.WhenAnyValue(x => x.SelectedItem)
@@ -66,6 +69,9 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
{
SelectedItem = null;
});
+
+ updateTrigger.Subscribe(async _ => await UpdateAsync());
+ RxApp.MainThreadScheduler.Schedule(async () => await UpdateAsync());
}
public ReadOnlyObservableCollection<HistoryItemViewModel> Transactions => _transactions;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/TransactionDetailsViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/TransactionDetailsViewModel.cs
using System;
using System.Linq;
+using System.Reactive;
using System.Reactive.Disposables;
-using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia;
@@ -21,6 +21,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
{
private readonly BitcoinStore _bitcoinStore;
private readonly Wallet _wallet;
+ private readonly IObservable<Unit> _updateTrigger;
[AutoNotify] private bool _isConfirmed;
[AutoNotify] private int _confirmations;
@@ -30,10 +31,11 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
[AutoNotify] private SmartLabel? _labels;
[AutoNotify] private uint256? _transactionId;
- public TransactionDetailsViewModel(TransactionSummary transactionSummary, BitcoinStore bitcoinStore, Wallet wallet)
+ public TransactionDetailsViewModel(TransactionSummary transactionSummary, BitcoinStore bitcoinStore, Wallet wallet, IObservable<Unit> updateTrigger)
{
_bitcoinStore = bitcoinStore;
_wallet = wallet;
+ _updateTrigger = updateTrigger;
NextCommand = ReactiveCommand.Create(OnNext);
CopyTransactionIdCommand = ReactiveCommand.CreateFromTask(OnCopyTransactionId);
@@ -73,10 +75,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
{
base.OnNavigatedTo(isInHistory, disposables);
- Observable.FromEventPattern(_wallet, nameof(_wallet.NewFilterProcessed))
- .Merge(Observable.FromEventPattern(_wallet.TransactionProcessor, nameof(_wallet.TransactionProcessor.WalletRelevantTransactionProcessed)))
- .Throttle(TimeSpan.FromSeconds(3))
- .ObserveOn(RxApp.MainThreadScheduler)
+ _updateTrigger
.Subscribe(async _ => await UpdateCurrentTransactionAsync())
.DisposeWith(disposables);
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
using ReactiveUI;
using System;
using System.Reactive;
-using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
-using System.Threading.Tasks;
using WalletWasabi.Fluent.ViewModels.Wallets.HardwareWallet;
using WalletWasabi.Fluent.ViewModels.Wallets.Home.History;
using WalletWasabi.Fluent.ViewModels.Wallets.Home.Tiles;
@@ -22,17 +20,15 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
? new CompositeDisposable()
: throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
- var balanceChanged = Observable.Merge(
- Observable.FromEventPattern(
- Wallet.TransactionProcessor,
- nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed))
- .Select(_ => Unit.Default))
+ var balanceChanged =
+ Observable.FromEventPattern(Wallet.TransactionProcessor, nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default)
.Throttle(TimeSpan.FromSeconds(0.1))
+ .Merge(Observable.FromEventPattern(Wallet, nameof(Wallet.NewFilterProcessed)).Select(_ => Unit.Default))
.Merge(uiConfig.WhenAnyValue(x => x.PrivacyMode).Select(_ => Unit.Default))
.Merge(Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Select(_ => Unit.Default))
.ObserveOn(RxApp.MainThreadScheduler);
- History = new HistoryViewModel(wallet, uiConfig);
+ History = new HistoryViewModel(wallet, uiConfig, balanceChanged);
BalanceTile = new WalletBalanceTileViewModel(wallet, balanceChanged);
BalanceChartTile = new WalletBalanceChartTileViewModel(History.Transactions);
WalletPieChart = new WalletPieChartTileViewModel(wallet, balanceChanged);
@@ -50,27 +46,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
public WalletPieChartTileViewModel WalletPieChart { get; }
- protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)
- {
- base.OnNavigatedTo(isInHistory, disposables);
-
- Observable.FromEventPattern(Wallet, nameof(Wallet.NewFilterProcessed))
- .Merge(Observable.FromEventPattern(
- Wallet.TransactionProcessor,
- nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)))
- .Throttle(TimeSpan.FromSeconds(3))
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(async _ => await UpdateAsync())
- .DisposeWith(disposables);
-
- RxApp.MainThreadScheduler.Schedule(async () => await UpdateAsync());
- }
-
- private async Task UpdateAsync()
- {
- await History.UpdateAsync();
- }
-
public static WalletViewModel Create(UiConfig uiConfig, Wallet wallet)
{
return wallet.KeyManager.IsHardwareWallet

use balanceChanged as a trigger