instead of clear just update the items
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryItemViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryItemViewModel.cs
@@ -5,16 +5,18 @@ using System.Reactive;
using System.Windows.Input;
using NBitcoin;
using ReactiveUI;
-using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Models;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
{
- public class HistoryItemViewModel : ViewModelBase
+ public partial class HistoryItemViewModel : ViewModelBase
{
- private bool _isSelected;
+ [AutoNotify] private bool _isSelected;
+ [AutoNotify] private bool _isConfirmed;
+ [AutoNotify] private int _orderIndex;
+ [AutoNotify] private DateTimeOffset _date;
public HistoryItemViewModel(int orderIndex, TransactionSummary transactionSummary, WalletViewModel walletViewModel, Money balance, IObservable<Unit> updateTrigger)
{
@@ -23,9 +25,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
IsCoinJoin = transactionSummary.IsLikelyCoinJoinOutput;
OrderIndex = orderIndex;
Balance = balance;
- var wallet = walletViewModel.Wallet;
- var confirmations = transactionSummary.Height.Type == HeightType.Chain ? (int)wallet.BitcoinStore.SmartHeaderChain.TipHeight - transactionSummary.Height.Value + 1 : 0;
+ var confirmations = transactionSummary.Height.Type == HeightType.Chain ? (int) Services.BitcoinStore.SmartHeaderChain.TipHeight - transactionSummary.Height.Value + 1 : 0;
IsConfirmed = confirmations > 0;
var amount = transactionSummary.Amount;
@@ -41,21 +42,15 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
Label = transactionSummary.Label.Take(1).ToList();
FilteredLabel = transactionSummary.Label.Skip(1).ToList();
- ShowDetailsCommand = ReactiveCommand.Create(() => RoutableViewModel.Navigate(NavigationTarget.DialogScreen).To(new TransactionDetailsViewModel(transactionSummary, wallet, updateTrigger)));
+ ShowDetailsCommand = ReactiveCommand.Create(() => RoutableViewModel.Navigate(NavigationTarget.DialogScreen).To(new TransactionDetailsViewModel(transactionSummary, walletViewModel.Wallet, updateTrigger)));
}
public ICommand ShowDetailsCommand { get; }
public TransactionSummary TransactionSummary { get; }
- public int OrderIndex { get; }
-
public Money Balance { get; set; }
- public DateTimeOffset Date { get; set; }
-
- public bool IsConfirmed { get; }
-
public Money? IncomingAmount { get; }
public Money? OutgoingAmount { get; }
@@ -66,10 +61,12 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
public bool IsCoinJoin { get; }
- public bool IsSelected
+ public void Update(HistoryItemViewModel item)
{
- get => _isSelected;
- set => this.RaiseAndSetIfChanged(ref _isSelected, value);
+ OrderIndex = item.OrderIndex;
+ Date = item.TransactionSummary.DateTime.ToLocalTime();
+ var confirmations = item.TransactionSummary.Height.Type == HeightType.Chain ? (int) Services.BitcoinStore.SmartHeaderChain.TipHeight - item.TransactionSummary.Height.Value + 1 : 0;
+ IsConfirmed = confirmations > 0;
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
@@ -90,14 +90,31 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
lock (_transactionListLock)
{
- _transactionSourceList.Clear();
+ var copyList = Transactions.ToList();
+
+ foreach (HistoryItemViewModel historyItemViewModel in copyList)
+ {
+ if (txRecordList.All(x => x.TransactionId != historyItemViewModel.TransactionSummary.TransactionId))
+ {
+ _transactionSourceList.Remove(historyItemViewModel);
+ }
+ }
Money balance = Money.Zero;
for (var i = 0; i < txRecordList.Count; i++)
{
var transactionSummary = txRecordList[i];
balance += transactionSummary.Amount;
- _transactionSourceList.Add(new HistoryItemViewModel(i, transactionSummary, _walletViewModel, balance, _updateTrigger));
+ var newItem = new HistoryItemViewModel(i, transactionSummary, _walletViewModel, balance, _updateTrigger);
+
+ if (_transactions.FirstOrDefault(x => x.TransactionSummary.TransactionId == newItem.TransactionSummary.TransactionId) is { } item)
+ {
+ item.Update(newItem);
+ }
+ else
+ {
+ _transactionSourceList.Add(newItem);
+ }
}
}
}

instead of clear just update the items