user DynamicData, filtering
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/History/HistoryViewModel.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
using DynamicData;
+using DynamicData.Binding;
using ReactiveUI;
using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Logging;
@@ -16,19 +17,41 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.History
{
private readonly Wallet _wallet;
private readonly BitcoinStore _bitcoinStore;
+ private readonly ReadOnlyObservableCollection<HistoryItemViewModel> _transactions;
+ private readonly SourceList<HistoryItemViewModel> _transactionSourceList;
- [AutoNotify] private ObservableCollection<HistoryItemViewModel> _transactions;
[AutoNotify] private bool _showCoinJoin;
public HistoryViewModel(Wallet wallet)
{
_wallet = wallet;
_bitcoinStore = wallet.BitcoinStore;
- _transactions = new ObservableCollection<HistoryItemViewModel>();
+ _transactionSourceList = new SourceList<HistoryItemViewModel>();
- this.WhenAnyValue(x => x.ShowCoinJoin)
+ var coinJoinFilter = this.WhenAnyValue(x => x.ShowCoinJoin).Select(CoinJoinFilter);
+
+ _transactionSourceList
+ .Connect()
+ .Filter(coinJoinFilter)
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(async _ => await UpdateAsync());
+ .Sort(SortExpressionComparer<HistoryItemViewModel>.Ascending(x => x.Date))
+ .Bind(out _transactions)
+ .Subscribe();
+ }
+
+ public ReadOnlyObservableCollection<HistoryItemViewModel> Transactions => _transactions;
+
+ private Func<HistoryItemViewModel, bool> CoinJoinFilter(bool showCoinJoin)
+ {
+ return item =>
+ {
+ if (!showCoinJoin)
+ {
+ return true;
+ }
+
+ return !item.IsCoinJoin;
+ };
}
public async Task UpdateAsync()
@@ -38,15 +61,9 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.History
var historyBuilder = new TransactionHistoryBuilder(_wallet);
var txRecordList = await Task.Run(historyBuilder.BuildHistorySummary);
- Transactions.Clear();
+ _transactionSourceList.Clear();
var trs = txRecordList.Select(transactionSummary => new HistoryItemViewModel(transactionSummary, _bitcoinStore));
-
- if (!ShowCoinJoin)
- {
- trs = trs.Where(x => !x.IsCoinJoin);
- }
-
- Transactions.AddRange(trs.Reverse());
+ _transactionSourceList.AddRange(trs.Reverse());
}
catch (Exception ex)
{

MODIFY
WalletWasabi.Fluent/Views/Wallets/History/HistoryTable.axaml
WalletWasabi.Fluent/Views/Wallets/History/HistoryTable.axaml
<DataGridTextColumn Header="Date / Time"
x:DataType="history:HistoryItemViewModel"
Binding="{Binding Date}"
- Width="*" />
+ Width="Auto" />
<!-- Incoming -->
<DataGridTemplateColumn Header="Incoming"

user DynamicData, filtering