Connect CoinListViewModel.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
@@ -17,6 +17,7 @@ using WalletWasabi.Gui.Models;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Logging;
using WalletWasabi.Coins;
+using WalletWasabi.Transactions;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -415,6 +416,27 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
})
.DisposeWith(Disposables);
+ Observable.FromEventPattern<ReplaceTransactionReceivedEventArgs>(Global.WalletService.TransactionProcessor, nameof(Global.WalletService.TransactionProcessor.ReplaceTransactionReceived))
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(args =>
+ {
+ var toRemove = args.EventArgs.DestroyedCoins;
+ RemoveCoins(RootList.Items.Where(cvm => toRemove.Any(sm => cvm.Model == sm)));
+
+ var toRestore = args.EventArgs.RestoredCoins;
+ AddCoins(toRestore);
+ })
+ .DisposeWith(Disposables);
+
+ Observable.FromEventPattern<DoubleSpendReceivedEventArgs>(Global.WalletService.TransactionProcessor, nameof(Global.WalletService.TransactionProcessor.DoubleSpendReceived))
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(args =>
+ {
+ var toRemove = args.EventArgs.Remove;
+ RemoveCoins(RootList.Items.Where(cvm => toRemove.Any(sm => cvm.Model == sm)));
+ })
+ .DisposeWith(Disposables);
+
SetSelections();
SetCoinJoinStatusWidth();
}
@@ -478,14 +500,36 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public void OnCoinUnspentChanged(CoinViewModel cvm)
{
if (!cvm.Unspent)
+ {
+ RemoveCoins(new[] { cvm });
+ }
+ else
+ {
+ SetSelections();
+ SetCoinJoinStatusWidth();
+ }
+ }
+
+ private void RemoveCoins(IEnumerable<CoinViewModel> cvms)
+ {
+ foreach (var cvm in cvms)
{
cvm.IsSelected = false;
RootList.Remove(cvm);
cvm.UnsubscribeEvents();
}
-
SetSelections();
SetCoinJoinStatusWidth();
}
+
+ private void AddCoins(IEnumerable<SmartCoin> coins)
+ {
+ foreach (var coin in coins)
+ {
+ var newCoinVm = new CoinViewModel(this, coin);
+ newCoinVm.SubscribeEvents();
+ RootList.Add(newCoinVm);
+ }
+ }
}
}

Connect CoinListViewModel.