move open wallet / selection logic into WalletExplorer.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ClosedWalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ClosedWalletViewModel.cs
@@ -49,15 +49,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Dispose();
- if (Wallet.Coins.Any())
- {
- // If already have coins then open the last active tab first.
- walletExplorer.OpenWallet(Wallet, receiveDominant: false, select: select);
- }
- else // Else open with Receive tab first.
- {
- walletExplorer.OpenWallet(Wallet, receiveDominant: true, select: select);
- }
+ walletExplorer.OpenClosedWallet(this);
});
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletExplorerViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletExplorerViewModel.cs
@@ -47,23 +47,45 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set => this.RaiseAndSetIfChanged(ref _selectedItem, value);
}
- internal void OpenWallet(Wallet wallet, bool receiveDominant, bool select = true)
+ internal WalletViewModelBase OpenWallet(Wallet wallet)
{
- if (_wallets.OfType<WalletViewModel>().Any(x => x.Title == wallet.WalletName))
+ if (wallet.Coins.Any())
+ {
+ // If already have coins then open the last active tab first.
+ return OpenWallet(wallet, receiveDominant: false);
+ }
+ else // Else open with Receive tab first.
{
- return;
+ return OpenWallet(wallet, receiveDominant: true);
+ }
}
- WalletViewModel walletViewModel = new WalletViewModel(wallet);
+ internal void OpenClosedWallet(ClosedWalletViewModel closedWalletViewModel)
+ {
+ var select = SelectedItem == closedWalletViewModel;
- Wallets.InsertSorted(walletViewModel);
+ var walletViewModel = OpenWallet(closedWalletViewModel.Wallet);
if (select)
{
SelectedItem = walletViewModel;
}
+ }
+
+ private WalletViewModelBase OpenWallet(Wallet wallet, bool receiveDominant, bool select = true)
+ {
+ if (_wallets.OfType<WalletViewModel>().Any(x => x.Title == wallet.WalletName))
+ {
+ throw new System.Exception("Wallet already opened.");
+ }
+
+ var walletViewModel = new WalletViewModel(wallet);
+
+ Wallets.InsertSorted(walletViewModel);
walletViewModel.OpenWallet(receiveDominant);
+
+ return walletViewModel;
}
internal void RemoveWallet(WalletViewModelBase wallet)

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModelBase.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModelBase.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set { this.RaiseAndSetIfChanged(ref _walletState, value); }
}
- protected Wallet Wallet { get; }
+ public Wallet Wallet { get; }
public bool IsExpanded
{

move open wallet / selection logic into WalletExplorer.