some major refactoring of login to support legal docs.
MODIFY
WalletWasabi.Fluent/ViewModels/Login/LoginViewModel.cs
WalletWasabi.Fluent/ViewModels/Login/LoginViewModel.cs
@@ -17,18 +17,24 @@ namespace WalletWasabi.Fluent.ViewModels.Login
[AutoNotify] private bool _isPasswordIncorrect;
[AutoNotify] private bool _isPasswordNeeded;
[AutoNotify] private string _walletName;
+ private readonly ClosedWalletViewModel _closedWalletVm;
- public LoginViewModel(WalletViewModelBase walletViewModelBase)
+ public LoginViewModel(ClosedWalletViewModel closedWalletVm)
{
- WalletViewModelBase = walletViewModelBase;
- KeyManager = walletViewModelBase.Wallet.KeyManager;
+ _closedWalletVm = closedWalletVm;
+
+ var wallet = _closedWalletVm.Wallet;
+
+ KeyManager = wallet.KeyManager;
IsPasswordNeeded = !KeyManager.IsWatchOnly;
- _walletName = walletViewModelBase.WalletName;
+
+ _walletName = wallet.WalletName;
_password = "";
- var wallet = walletViewModelBase.Wallet;
NextCommand = ReactiveCommand.CreateFromTask(async () =>
{
+ IsBusy = true;
+
IsPasswordIncorrect = await Task.Run(async () =>
{
if (!IsPasswordNeeded)
@@ -49,6 +55,8 @@ namespace WalletWasabi.Fluent.ViewModels.Login
return true;
});
+ await _closedWalletVm.LoadWallet();
+
if (!IsPasswordIncorrect)
{
var legalChecker = wallet.Synchronizer.LegalChecker;
@@ -70,6 +78,8 @@ namespace WalletWasabi.Fluent.ViewModels.Login
LoginWallet();
}
}
+
+ IsBusy = false;
});
OkCommand = ReactiveCommand.Create(() =>
@@ -84,8 +94,6 @@ namespace WalletWasabi.Fluent.ViewModels.Login
EnableAutoBusyOn(NextCommand);
}
- private WalletViewModelBase WalletViewModelBase { get; }
-
public ICommand OkCommand { get; }
public ICommand ForgotPasswordCommand { get; }
@@ -94,9 +102,9 @@ namespace WalletWasabi.Fluent.ViewModels.Login
private void LoginWallet()
{
- WalletViewModelBase.Wallet.Login();
- WalletViewModelBase.RaisePropertyChanged(nameof(WalletViewModelBase.IsLoggedIn));
- Navigate().To(WalletViewModelBase, NavigationMode.Clear);
+ _closedWalletVm.Wallet.Login();
+ _closedWalletVm.RaisePropertyChanged(nameof(WalletViewModelBase.IsLoggedIn));
+ Navigate().To(_closedWalletVm, NavigationMode.Clear);
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/ClosedWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/ClosedWalletViewModel.cs
using System;
using System.Collections.ObjectModel;
-using System.Reactive.Disposables;
using System.Threading.Tasks;
+using ReactiveUI;
+using WalletWasabi.Fluent.ViewModels.Login;
using WalletWasabi.Fluent.ViewModels.NavBar;
using WalletWasabi.Fluent.ViewModels.Wallets.HardwareWallet;
using WalletWasabi.Fluent.ViewModels.Wallets.WatchOnlyWallet;
using WalletWasabi.Logging;
-using WalletWasabi.Nito.AsyncEx;
using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets
@@ -14,34 +14,35 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
public partial class ClosedWalletViewModel : WalletViewModelBase
{
[AutoNotify] private ObservableCollection<NavBarItemViewModel> _items;
+ private readonly WalletManager _walletManager;
protected ClosedWalletViewModel(WalletManager walletManager, Wallet wallet)
: base(wallet)
{
- WalletManager = walletManager;
+ _walletManager = walletManager;
_items = new ObservableCollection<NavBarItemViewModel>();
- }
- public WalletManager WalletManager { get; }
+ OpenCommand = ReactiveCommand.Create(() =>
+ {
+ if (!Wallet.IsLoggedIn)
+ {
+ Navigate().To(new LoginViewModel(this));
+ }
+ });
+ }
public override string IconName => "web_asset_regular";
- protected override void OnNavigatedTo(bool inStack, CompositeDisposable disposable)
+ public async Task LoadWallet()
{
- base.OnNavigatedTo(inStack, disposable);
-
- if (Wallet.State == WalletState.Uninitialized)
+ if (Wallet.State != WalletState.Uninitialized)
{
- AbandonedTasks abandonedTasks = new();
- abandonedTasks.AddAndClearCompleted(LoadWallet());
- }
+ return;
}
- private async Task LoadWallet()
- {
try
{
- await Task.Run(async () => await WalletManager.StartWalletAsync(Wallet));
+ await Task.Run(async () => await _walletManager.StartWalletAsync(Wallet));
}
catch (OperationCanceledException ex)
{

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModelBase.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletViewModelBase.cs
@@ -36,18 +36,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
.Subscribe(x => WalletState = x.EventArgs)
.DisposeWith(_disposables);
- OpenCommand = ReactiveCommand.Create(() =>
- {
- if (!Wallet.IsLoggedIn)
- {
- Navigate().To(new LoginViewModel(this));
- }
- else
- {
- // TODO: wallet welcome page
- Navigate().To(this);
- }
- });
+ OpenCommand = ReactiveCommand.Create(() => Navigate().To(this));
}
public override string Title

some major refactoring of login to support legal docs.