ClosedWalletViewModel responds to state changes.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ClosedWalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ClosedWalletViewModel.cs
@@ -2,7 +2,6 @@ using AvalonStudio.Extensibility;
using ReactiveUI;
using Splat;
using System;
-using System.IO;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
@@ -21,8 +20,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
try
{
- IsBusy = true;
-
var global = Locator.Current.GetService<Global>();
if (!await global.WaitForInitializationCompletedAsync(CancellationToken.None))
@@ -30,34 +27,38 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
return;
}
- await global.WalletManager.StartWalletAsync(wallet);
+ await global.WalletManager.StartWalletAsync(Wallet);
+ }
+ catch (Exception e)
+ {
+ NotificationHelpers.Error($"Error loading Wallet: {Title}");
+ Logger.LogError(e.Message);
+ }
+ }, this.WhenAnyValue(x => x.IsBusy).Select(x => !x));
+ this.WhenAnyValue(x => x.WalletState)
+ .Where(x => x == WalletState.Started)
+ .Take(1)
+ .Subscribe(x =>
+ {
var walletExplorer = IoC.Get<WalletExplorerViewModel>();
var select = walletExplorer.SelectedItem == this;
walletExplorer.RemoveWallet(this);
- if (wallet.Coins.Any())
+ Dispose();
+
+ if (Wallet.Coins.Any())
{
// If already have coins then open the last active tab first.
- walletExplorer.OpenWallet(wallet, receiveDominant: false, select: select);
+ walletExplorer.OpenWallet(Wallet, receiveDominant: false, select: select);
}
else // Else open with Receive tab first.
{
- walletExplorer.OpenWallet(wallet, receiveDominant: true, select: select);
+ walletExplorer.OpenWallet(Wallet, receiveDominant: true, select: select);
}
- }
- catch (Exception e)
- {
- NotificationHelpers.Error($"Error loading Wallet: {Title}");
- Logger.LogError(e.Message);
- }
- finally
- {
- IsBusy = false;
- }
- }, this.WhenAnyValue(x => x.IsBusy).Select(x => !x));
+ });
}
public ReactiveCommand<Unit, Unit> OpenWalletCommand { get; }

ClosedWalletViewModel responds to state changes.