introduce DoAndRun
MODIFY
WalletWasabi.Fluent/Extensions/ObservableExtensions.cs
WalletWasabi.Fluent/Extensions/ObservableExtensions.cs
using System.Reactive;
using System.Reactive.Linq;
+using System.Reactive.Subjects;
using System.Threading.Tasks;
namespace WalletWasabi.Fluent.Extensions;
@@ -17,6 +18,18 @@ public static class ObservableExtensions
.Select(x => Observable.FromAsync(() => onNextAsync(x)))
.Concat();
+ public static IObservable<Unit> DoAndRunOnceAsync<T>(this IObservable<T> source, Func<T, Task> onNextAsync, T value)
+ {
+ var subject = new Subject<T>();
+ subject
+ .DoAsync(async x => await onNextAsync(x))
+ .Take(1)
+ .Subscribe();
+ subject.OnNext(value);
+
+ return source.Select(x => Observable.FromAsync(() => onNextAsync(x))).Concat();
+ }
+
public static IObservable<Unit> ToSignal<T>(this IObservable<T> source) => source.Select(_ => Unit.Default);
public static IObservable<T> ReplayLastActive<T>(this IObservable<T> observable)

MODIFY
WalletWasabi.Fluent/Models/UiUpdateTriggers.cs
WalletWasabi.Fluent/Models/UiUpdateTriggers.cs
@@ -22,30 +22,11 @@ public class UiUpdateTriggers
public IObservable<Unit> WalletRelevantTransactionProcessed =>
Observable.FromEventPattern(_wallet.TransactionProcessor, nameof(TransactionProcessor.WalletRelevantTransactionProcessed)).ToSignal();
- public IObservable<Unit> PrivacyModeChanged => Services.UiConfig.WhenAnyValue(x => x.PrivacyMode).ToSignal();
-
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);
+ public IObservable<Unit> BalanceUpdateTrigger => WalletRelevantTransactionProcessed.Merge(UsdExchangeRateChanged);
+ public IObservable<Unit> PrivacyProgressUpdateTrigger => WalletRelevantTransactionProcessed.Merge(AnonScoreTargetChanged);
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
@@ -41,7 +41,7 @@ public partial class HistoryViewModel : ActivatableViewModel
public HistoryViewModel(WalletViewModel walletViewModel)
{
_walletViewModel = walletViewModel;
- _updateTrigger = _walletViewModel.UiUpdateTriggers.TransactionHistoryUpdateTrigger;
+ _updateTrigger = _walletViewModel.UiUpdateTriggers.WalletRelevantTransactionProcessed;
_transactionSourceList = new SourceList<HistoryItemViewModelBase>();
_transactions = new ObservableCollectionExtended<HistoryItemViewModelBase>();
_unfilteredTransactions = new ObservableCollectionExtended<HistoryItemViewModelBase>();
@@ -210,7 +210,8 @@ public partial class HistoryViewModel : ActivatableViewModel
base.OnActivated(disposables);
_updateTrigger
- .SubscribeAsync(async _ => await UpdateAsync())
+ .DoAndRunOnceAsync(async _ => await UpdateAsync(), Unit.Default)
+ .Subscribe()
.DisposeWith(disposables);
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
@@ -163,7 +163,7 @@ public partial class WalletViewModel : WalletViewModelBase
WalletSettingsCommand = ReactiveCommand.Create(() => Navigate(NavigationTarget.DialogScreen).To(Settings));
- WalletCoinsCommand = ReactiveCommand.Create(() => Navigate(NavigationTarget.DialogScreen).To(new WalletCoinsViewModel(this, UiUpdateTriggers.TransactionHistoryUpdateTrigger)));
+ WalletCoinsCommand = ReactiveCommand.Create(() => Navigate(NavigationTarget.DialogScreen).To(new WalletCoinsViewModel(this, UiUpdateTriggers.WalletRelevantTransactionProcessed)));
CoinJoinSettingsCommand = ReactiveCommand.Create(() => Navigate(NavigationTarget.DialogScreen).To(CoinJoinSettings), Observable.Return(!wallet.KeyManager.IsWatchOnly));

introduce DoAndRun