move showing txn details to walletviewmodel.
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
@@ -5,16 +5,13 @@ using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
-using Avalonia.Threading;
using DynamicData;
using DynamicData.Binding;
using NBitcoin;
using ReactiveUI;
using WalletWasabi.Blockchain.Transactions;
-using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Gui;
using WalletWasabi.Logging;
-using WalletWasabi.Stores;
using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
@@ -22,7 +19,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
public partial class HistoryViewModel : ActivatableViewModel
{
private readonly Wallet _wallet;
- private readonly BitcoinStore _bitcoinStore;
private readonly SourceList<HistoryItemViewModel> _transactionSourceList;
private readonly IObservable<Unit> _updateTrigger;
private readonly ObservableCollectionExtended<HistoryItemViewModel> _transactions;
@@ -31,11 +27,10 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
[AutoNotify] private bool _showCoinJoin;
[AutoNotify] private HistoryItemViewModel? _selectedItem;
- public HistoryViewModel(INavigationStack<RoutableViewModel> dialogNavigationStack, Wallet wallet, UiConfig uiConfig, IObservable<Unit> updateTrigger)
+ public HistoryViewModel(Wallet wallet, UiConfig uiConfig, IObservable<Unit> updateTrigger)
{
_updateTrigger = updateTrigger;
_wallet = wallet;
- _bitcoinStore = wallet.BitcoinStore;
_showCoinJoin = uiConfig.ShowCoinJoinInHistory;
_transactionSourceList = new SourceList<HistoryItemViewModel>();
_transactions = new ObservableCollectionExtended<HistoryItemViewModel>();
@@ -44,22 +39,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
this.WhenAnyValue(x => x.ShowCoinJoin)
.Subscribe(showCoinJoin => uiConfig.ShowCoinJoinInHistory = showCoinJoin);
- this.WhenAnyValue(x => x.SelectedItem)
- .Subscribe(async selectedItem =>
- {
- if (selectedItem is null)
- {
- return;
- }
-
- dialogNavigationStack.To(new TransactionDetailsViewModel(selectedItem.TransactionSummary, _bitcoinStore, wallet, updateTrigger));
-
- Dispatcher.UIThread.Post(() =>
- {
- SelectedItem = null;
- });
- });
-
RxApp.MainThreadScheduler.Schedule(async () => await UpdateAsync());
}
@@ -115,7 +94,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
{
var transactionSummary = txRecordList[i];
balance += transactionSummary.Amount;
- _transactionSourceList.Add(new HistoryItemViewModel(i, transactionSummary, _bitcoinStore, balance));
+ _transactionSourceList.Add(new HistoryItemViewModel(i, transactionSummary, _wallet.BitcoinStore, balance));
}
}
catch (Exception ex)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/TransactionDetailsViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/TransactionDetailsViewModel.cs
@@ -19,7 +19,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
[NavigationMetaData(Title = "Transaction Details")]
public partial class TransactionDetailsViewModel : RoutableViewModel
{
- private readonly BitcoinStore _bitcoinStore;
private readonly Wallet _wallet;
private readonly IObservable<Unit> _updateTrigger;
@@ -31,9 +30,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
[AutoNotify] private SmartLabel? _labels;
[AutoNotify] private uint256? _transactionId;
- public TransactionDetailsViewModel(TransactionSummary transactionSummary, BitcoinStore bitcoinStore, Wallet wallet, IObservable<Unit> updateTrigger)
+ public TransactionDetailsViewModel(TransactionSummary transactionSummary, Wallet wallet, IObservable<Unit> updateTrigger)
{
- _bitcoinStore = bitcoinStore;
_wallet = wallet;
_updateTrigger = updateTrigger;
@@ -63,7 +61,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Home.History
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)_wallet.BitcoinStore.SmartHeaderChain.TipHeight - transactionSummary.Height.Value + 1 : 0;
IsConfirmed = Confirmations > 0;
Amount = transactionSummary.Amount.ToString(fplus: false);
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModel.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
+using Avalonia.Threading;
using WalletWasabi.Fluent.ViewModels.Wallets.HardwareWallet;
using WalletWasabi.Fluent.ViewModels.Wallets.Home.History;
using WalletWasabi.Fluent.ViewModels.Wallets.Home.Tiles;
@@ -35,7 +36,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
.Merge(Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Select(_ => Unit.Default))
.ObserveOn(RxApp.MainThreadScheduler);
- History = new HistoryViewModel(Navigate(NavigationTarget.DialogScreen), wallet, uiConfig, balanceChanged);
+ History = new HistoryViewModel(wallet, uiConfig, balanceChanged);
BalanceTile = new WalletBalanceTileViewModel(wallet, balanceChanged);
BalanceChartTile = new WalletBalanceChartTileViewModel(History.UnfilteredTransactions);
@@ -51,6 +52,23 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
RoundStatusTile,
BtcPriceTile
};
+
+ History.WhenAnyValue(x=>x.SelectedItem)
+ .Subscribe(async selectedItem =>
+ {
+ if (selectedItem is null)
+ {
+ return;
+ }
+
+ Navigate(NavigationTarget.DialogScreen)
+ .To(new TransactionDetailsViewModel(selectedItem.TransactionSummary, wallet, balanceChanged));
+
+ Dispatcher.UIThread.Post(() =>
+ {
+ History.SelectedItem = null;
+ });
+ });
}
private CompositeDisposable Disposables { get; set; }

move showing txn details to walletviewmodel.