remove unspent items
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
@@ -188,10 +188,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public CoinListViewModel(Money preSelectMinAmountIncludingCondition = null, int? preSelectMaxAnonSetExcludingCondition = null)
{
- foreach (var sc in Global.WalletService.Coins)
- {
- _rootlist.Add(new CoinViewModel(sc));
- }
AmountSortDirection = SortOrder.Decreasing;
RefreshOrdering();
@@ -201,17 +197,20 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
MyComparer);
_rootlist.Connect()
- .AutoRefresh(sm => sm.Model.Unspent)
- .Filter(sm => sm.Unspent)
+ .ObserveOn(RxApp.MainThreadScheduler)
.OnItemAdded(cvm =>
cvm.PropertyChanged += Coin_PropertyChanged)
.OnItemRemoved(cvm =>
cvm.PropertyChanged -= Coin_PropertyChanged)
- .Sort(MyComparer, SortOptions.UseBinarySearch, comparerChanged: sortChanged, resetThreshold: 50)
+ .Sort(MyComparer, comparerChanged: sortChanged)
.Bind(out _coinViewModels)
- .ObserveOn(RxApp.MainThreadScheduler)
.Subscribe();
+ foreach (var sc in Global.WalletService.Coins.Where(sc => sc.Unspent))
+ {
+ _rootlist.Add(new CoinViewModel(sc));
+ }
+
Global.WalletService.Coins.CollectionChanged += Coins_CollectionGlobalChanged;
this.WhenAnyValue(x => x.AmountSortDirection).Subscribe(x =>
@@ -333,8 +332,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
private void Coins_CollectionGlobalChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- Dispatcher.UIThread.Post(() =>
{
switch (e.Action)
{
@@ -352,7 +349,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
_rootlist.Clear();
break;
}
- });
}
private void SetSelections()
@@ -381,6 +377,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
private void Coin_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ Dispatcher.UIThread.Post(() =>
{
if (e.PropertyName == nameof(CoinViewModel.IsSelected))
{
@@ -390,6 +388,13 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
SetCoinJoinStatusWidth();
}
+ if (e.PropertyName == nameof(CoinViewModel.Unspent))
+ {
+ var cvm = (CoinViewModel)sender;
+ if (!cvm.Unspent)
+ _rootlist.Remove(cvm);
+ }
+ });
}
}
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
@@ -49,6 +49,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
RefreshSmartCoinStatus();
});
+ model.WhenAnyValue(x => x.Unspent).ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
+ {
+ this.RaisePropertyChanged(nameof(Unspent));
+ });
+
Global.IndexDownloader.WhenAnyValue(x => x.BestHeight).ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
{
RefreshSmartCoinStatus();

remove unspent items