make transactions details live
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
@@ -56,7 +56,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
return;
}
- Navigate(NavigationTarget.DialogScreen).To(new TransactionDetailsViewModel(selectedItem.TransactionSummary, _bitcoinStore));
+ Navigate(NavigationTarget.DialogScreen).To(new TransactionDetailsViewModel(selectedItem.TransactionSummary, _bitcoinStore, wallet));
});
this.WhenAnyValue(x => x.SelectedItem)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/TransactionDetailsViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/TransactionDetailsViewModel.cs
using System;
+using System.Linq;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+using System.Threading.Tasks;
using NBitcoin;
using ReactiveUI;
using WalletWasabi.Blockchain.Analysis.Clustering;
@@ -6,42 +10,73 @@ using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Models;
using WalletWasabi.Stores;
+using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
{
[NavigationMetaData(Title = "Transaction Details")]
public partial class TransactionDetailsViewModel : RoutableViewModel
{
- public TransactionDetailsViewModel(TransactionSummary transactionSummary, BitcoinStore bitcoinStore)
+ private readonly BitcoinStore _bitcoinStore;
+ private readonly Wallet _wallet;
+
+ [AutoNotify] private bool _isConfirmed;
+ [AutoNotify] private int _confirmations;
+ [AutoNotify] private int _blockHeight;
+ [AutoNotify] private DateTimeOffset _date;
+ [AutoNotify] private string? _amount;
+ [AutoNotify] private SmartLabel? _labels;
+ [AutoNotify] private uint256? _transactionId;
+
+ public TransactionDetailsViewModel(TransactionSummary transactionSummary, BitcoinStore bitcoinStore, Wallet wallet)
+ {
+ _bitcoinStore = bitcoinStore;
+ _wallet = wallet;
+
+ NextCommand = ReactiveCommand.Create(OnNext);
+
+ UpdateValues(transactionSummary);
+ }
+
+ private void UpdateValues(TransactionSummary transactionSummary)
{
Date = transactionSummary.DateTime.ToLocalTime();
- TransactionId = transactionSummary.TransactionId.ToString();
+ TransactionId = transactionSummary.TransactionId;
Labels = transactionSummary.Label;
BlockHeight = transactionSummary.Height.Type == HeightType.Chain ? transactionSummary.Height.Value : 0;
- Confirmations = transactionSummary.Height.Type == HeightType.Chain ? (int) bitcoinStore.SmartHeaderChain.TipHeight - transactionSummary.Height.Value + 1 : 0;
+ Confirmations = transactionSummary.Height.Type == HeightType.Chain ? (int) _bitcoinStore.SmartHeaderChain.TipHeight - transactionSummary.Height.Value + 1 : 0;
IsConfirmed = Confirmations > 0;
Amount = transactionSummary.Amount.ToString(fplus: false);
-
- NextCommand = ReactiveCommand.Create(OnNext);
}
- public string Amount { get; set; }
-
- public bool IsConfirmed { get; set; }
-
- public int Confirmations { get; set; }
+ private void OnNext()
+ {
+ Navigate().Clear();
+ }
- public int BlockHeight { get; set; }
+ protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)
+ {
+ base.OnNavigatedTo(isInHistory, disposables);
- public SmartLabel Labels { get; set; }
+ Observable.FromEventPattern(_wallet, nameof(_wallet.NewFilterProcessed))
+ .Merge(Observable.FromEventPattern(_wallet.TransactionProcessor, nameof(_wallet.TransactionProcessor.WalletRelevantTransactionProcessed)))
+ .Throttle(TimeSpan.FromSeconds(3))
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(async _ => await UpdateCurrentTransactionAsync())
+ .DisposeWith(disposables);
+ }
- public string TransactionId { get; set; }
+ private async Task UpdateCurrentTransactionAsync()
+ {
+ var historyBuilder = new TransactionHistoryBuilder(_wallet);
+ var txRecordList = await Task.Run(historyBuilder.BuildHistorySummary);
- public DateTimeOffset Date { get; set; }
+ var currentTransaction = txRecordList.FirstOrDefault(x => x.TransactionId == TransactionId);
- private void OnNext()
+ if (currentTransaction is { })
{
- Navigate().Clear();
+ UpdateValues(currentTransaction);
+ }
}
}
}

make transactions details live