huge cleanup
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryItems/CoinJoinsHistoryItemViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryItems/CoinJoinsHistoryItemViewModel.cs
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Linq;
using NBitcoin;
using ReactiveUI;
@@ -40,28 +41,13 @@ public class CoinJoinsHistoryItemViewModel : HistoryItemViewModelBase
{
IsConfirmed = CoinJoinTransactions.All(x => x.IsConfirmed());
Date = CoinJoinTransactions.Select(tx => tx.DateTime).Max().ToLocalTime();
- UpdateAmount();
+ OutgoingAmount = CoinJoinTransactions.Sum(x => x.Amount) * -1;
UpdateDateString();
}
- public override void Update(HistoryItemViewModelBase item)
- {
- if (item is not CoinJoinsHistoryItemViewModel coinJoinHistoryItemViewModel)
- {
- throw new InvalidOperationException("Not the same type!");
- }
-
- CoinJoinTransactions = coinJoinHistoryItemViewModel.CoinJoinTransactions;
- UpdateAmount();
-
- base.Update(item);
-
- this.RaisePropertyChanged();
- }
-
protected void UpdateDateString()
{
- var dates = CoinJoinTransactions.Select(tx => tx.DateTime);
+ var dates = CoinJoinTransactions.Select(tx => tx.DateTime).ToImmutableArray();
var firstDate = dates.Min().ToLocalTime();
var lastDate = dates.Max().ToLocalTime();
@@ -70,11 +56,6 @@ public class CoinJoinsHistoryItemViewModel : HistoryItemViewModelBase
: $"{firstDate:MM/dd/yy} - {lastDate:MM/dd/yy}";
}
- private void UpdateAmount()
- {
- OutgoingAmount = CoinJoinTransactions.Sum(x => x.Amount) * -1;
- }
-
public void SetBalance(Money balance)
{
Balance = balance;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryItems/HistoryItemViewModelBase.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryItems/HistoryItemViewModelBase.cs
@@ -47,16 +47,6 @@ public abstract partial class HistoryItemViewModelBase : ViewModelBase
public ICommand? ShowDetailsCommand { get; protected set; }
- public virtual void Update(HistoryItemViewModelBase item)
- {
- OrderIndex = item.OrderIndex;
- Date = item.Date;
- DateString = item.DateString;
- IsConfirmed = item.IsConfirmed;
- }
-
- public bool IsSimilar(HistoryItemViewModelBase item) => Id == item.Id;
-
public static Comparison<HistoryItemViewModelBase?> SortAscending<T>(Func<HistoryItemViewModelBase, T> selector)
{
return (x, y) =>

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
@@ -30,11 +30,14 @@ public partial class HistoryViewModel : ActivatableViewModel
private readonly IObservable<Unit> _updateTrigger;
private readonly ObservableCollectionExtended<HistoryItemViewModelBase> _transactions;
private readonly ObservableCollectionExtended<HistoryItemViewModelBase> _unfilteredTransactions;
- private readonly object _transactionListLock = new();
[AutoNotify] private HistoryItemViewModelBase? _selectedItem;
- [AutoNotify(SetterModifier = AccessModifier.Private)] private bool _isTransactionHistoryEmpty;
- [AutoNotify(SetterModifier = AccessModifier.Private)] private bool _isInitialized;
+
+ [AutoNotify(SetterModifier = AccessModifier.Private)]
+ private bool _isTransactionHistoryEmpty;
+
+ [AutoNotify(SetterModifier = AccessModifier.Private)]
+ private bool _isInitialized;
public HistoryViewModel(WalletViewModel walletViewModel, IObservable<Unit> updateTrigger)
{
@@ -210,39 +213,10 @@ public partial class HistoryViewModel : ActivatableViewModel
var rawHistoryList = await Task.Run(historyBuilder.BuildHistorySummary);
var newHistoryList = GenerateHistoryList(rawHistoryList).ToArray();
- lock (_transactionListLock)
- {
_transactionSourceList.Edit(x =>
{
- var copyList = Transactions.ToList();
-
- foreach (var oldItem in copyList)
- {
- if (newHistoryList.All(x => x.Id != oldItem.Id))
- {
- x.Remove(oldItem);
- }
- }
-
- foreach (var newItem in newHistoryList)
- {
- if (_transactions.FirstOrDefault(x => x.Id == newItem.Id) is { } item)
- {
- if (item.GetType() != newItem.GetType())
- {
- x.Remove(item);
- x.Add(newItem);
- }
- else
- {
- item.Update(newItem);
- }
- }
- else
- {
- x.Add(newItem);
- }
- }
+ x.Clear();
+ x.AddRange(newHistoryList);
});
if (!IsInitialized)
@@ -250,7 +224,6 @@ public partial class HistoryViewModel : ActivatableViewModel
IsInitialized = true;
}
}
- }
catch (Exception ex)
{
Logger.LogError(ex);

huge cleanup