load wallet automatically
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/ClosedWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/ClosedWalletViewModel.cs
-using ReactiveUI;
using System;
using System.Collections.ObjectModel;
-using System.Reactive;
-using System.Reactive.Linq;
+using System.Reactive.Disposables;
using System.Threading.Tasks;
using WalletWasabi.Fluent.ViewModels.NavBar;
using WalletWasabi.Fluent.ViewModels.Wallets.HardwareWallet;
using WalletWasabi.Fluent.ViewModels.Wallets.WatchOnlyWallet;
-using WalletWasabi.Gui.Helpers;
using WalletWasabi.Logging;
+using WalletWasabi.Nito.AsyncEx;
using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets
@@ -20,19 +18,30 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
protected ClosedWalletViewModel(WalletManager walletManager, Wallet wallet)
: base(wallet)
{
+ WalletManager = walletManager;
_items = new ObservableCollection<NavBarItemViewModel>();
+ }
- OpenWalletCommand = ReactiveCommand.CreateFromTask(
- async () =>
- {
- try
+ public WalletManager WalletManager { get; }
+
+ public override string IconName => "web_asset_regular";
+
+ protected override void OnNavigatedTo(bool inStack, CompositeDisposable disposable)
{
- if (wallet.KeyManager.PasswordVerified is true)
+ base.OnNavigatedTo(inStack, disposable);
+
+ if (Wallet.State == WalletState.Uninitialized)
{
- // TODO ... new UX will test password earlier...
+ AbandonedTasks abandonedTasks = new();
+ abandonedTasks.AddAndClearCompleted(LoadWallet());
+ }
}
- await Task.Run(async () => await walletManager.StartWalletAsync(Wallet));
+ private async Task LoadWallet()
+ {
+ try
+ {
+ await Task.Run(async () => await WalletManager.StartWalletAsync(Wallet));
}
catch (OperationCanceledException ex)
{
@@ -40,17 +49,11 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets
}
catch (Exception ex)
{
- NotificationHelpers.Error($"Couldn't load wallet. Reason: {ex.ToUserFriendlyString()}", sender: wallet);
+ await ShowErrorAsync(ex.ToUserFriendlyString(), "Wasabi was unable to load your wallet");
Logger.LogError(ex);
}
- },
- this.WhenAnyValue(x => x.WalletState).Select(x => x == WalletState.Uninitialized));
}
- public ReactiveCommand<Unit, Unit> OpenWalletCommand { get; }
-
- public override string IconName => "web_asset_regular";
-
public static WalletViewModelBase Create(WalletManager walletManager, Wallet wallet)
{
return wallet.KeyManager.IsHardwareWallet

MODIFY
WalletWasabi.Fluent/Views/Wallets/ClosedWalletView.axaml
WalletWasabi.Fluent/Views/Wallets/ClosedWalletView.axaml
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="WalletWasabi.Fluent.Views.Wallets.ClosedWalletView">
- <StackPanel>
- <Button Command="{Binding OpenWalletCommand}">Load</Button>
- </StackPanel>
+ <c:ProgressRing Margin="15" IsIndeterminate="True" Height="100" Width="100" VerticalAlignment="Center" HorizontalAlignment="Center" />
</UserControl>

RENAME
WalletWasabi.Fluent/Views/Wallets/ClosedHardwareWalletView.axaml
WalletWasabi.Fluent/Views/Wallets/HardwareWallet/ClosedHardwareWalletView.axaml
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
- x:Class="WalletWasabi.Fluent.Views.Wallets.ClosedHardwareWalletView">
- <StackPanel>
- <Button Command="{Binding OpenWalletCommand}">Load</Button>
- </StackPanel>
+ x:Class="WalletWasabi.Fluent.Views.Wallets.HardwareWallet.ClosedHardwareWalletView">
+ <c:ProgressRing Margin="15" IsIndeterminate="True" Height="100" Width="100" VerticalAlignment="Center" HorizontalAlignment="Center" />
</UserControl>

RENAME
WalletWasabi.Fluent/Views/Wallets/ClosedHardwareWalletView.axaml.cs
WalletWasabi.Fluent/Views/Wallets/HardwareWallet/ClosedHardwareWalletView.axaml.cs
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
-namespace WalletWasabi.Fluent.Views.Wallets
+namespace WalletWasabi.Fluent.Views.Wallets.HardwareWallet
{
public class ClosedHardwareWalletView : UserControl
{

load wallet automatically