Use GetOrCreate
MODIFY
WalletWasabi.Gui/Helpers/AvaloniaExtensions.cs
WalletWasabi.Gui/Helpers/AvaloniaExtensions.cs
@@ -9,11 +9,6 @@ namespace Avalonia
{
public static class AvaloniaExtensions
{
- public static T GetDocument<T>(this IShell shell)
- {
- return shell.Documents.OfType<T>().Single();
- }
-
public static void AddOrReplace(this IResourceDictionary resources, object key, object value)
{
if (resources.TryGetResource(key.ToString(), out _))

MODIFY
WalletWasabi.Gui/Shell/Commands/WalletCommands.cs
WalletWasabi.Gui/Shell/Commands/WalletCommands.cs
@@ -33,17 +33,17 @@ namespace WalletWasabi.Gui.Shell.Commands
private void OnGenerateWallet()
{
- IoC.Get<IShell>().GetDocument<WalletManagerViewModel>().SelectGenerateWallet();
+ IoC.Get<IShell>().GetOrCreate<WalletManagerViewModel>().SelectGenerateWallet();
}
private void OnRecoverWallet()
{
- IoC.Get<IShell>().GetDocument<WalletManagerViewModel>().SelectRecoverWallet();
+ IoC.Get<IShell>().GetOrCreate<WalletManagerViewModel>().SelectRecoverWallet();
}
private void OnLoadWallet()
{
- IoC.Get<IShell>().GetDocument<WalletManagerViewModel>().SelectLoadWallet();
+ IoC.Get<IShell>().GetOrCreate<WalletManagerViewModel>().SelectLoadWallet();
}
[ExportCommandDefinition("File.GenerateWallet")]

Use GetOrCreate