Code clean, better implementation.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
@@ -253,15 +253,17 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
SelectPrivateCheckBoxState = false;
SelectNonPrivateCheckBoxState = false;
- var sortChanged = this.WhenValueChanged(@this => MyComparer)
+ var sortChanged = this
+ .WhenAnyValue(x => x.MyComparer)
.ObserveOn(RxApp.MainThreadScheduler)
.Select(_ => MyComparer);
RootList = new SourceList<CoinViewModel>();
- RootList.Connect()
+ RootList
+ .Connect()
.Sort(MyComparer, comparerChanged: sortChanged, resetThreshold: 5)
- .Bind(out _coinViewModels)
.ObserveOn(RxApp.MainThreadScheduler)
+ .Bind(out _coinViewModels)
.Subscribe();
SortCommand = ReactiveCommand.Create(RefreshOrdering);
@@ -332,8 +334,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
DequeueCoinsPressed?.Invoke(this, EventArgs.Empty);
},
- this.WhenAnyValue(x => x.CanDeqeue)
- .ObserveOn(RxApp.MainThreadScheduler));
+ this.WhenAnyValue(x => x.CanDeqeue));
SelectAllCheckBoxCommand = ReactiveCommand.Create(() =>
{
@@ -415,14 +416,17 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");
- foreach (var sc in Global.WalletService.Coins)
+ var list = Global.WalletService.Coins.Select(x => new CoinViewModel(this, x)).ToList();
+
+ foreach (var vm in list)
{
- var newCoinVm = new CoinViewModel(this, sc);
- newCoinVm.SubscribeEvents();
- RootList.Add(newCoinVm);
+ vm.SubscribeEvents();
}
- Global.UiConfig.WhenAnyValue(x => x.LurkingWifeMode)
+ RootList.AddRange(list);
+
+ Global.UiConfig
+ .WhenAnyValue(x => x.LurkingWifeMode)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => this.RaisePropertyChanged(nameof(SelectedAmount)))
.DisposeWith(Disposables);
@@ -504,7 +508,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
})
.DisposeWith(Disposables);
- Global.Config.WhenAnyValue(x => x.MixUntilAnonymitySet)
+ Global.Config
+ .WhenAnyValue(x => x.MixUntilAnonymitySet)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x => RefreshSelectCheckBoxesShields(x))
.DisposeWith(Disposables);

Code clean, better implementation.