remove initialisation of legacy stuff from old ui project.
MODIFY
WalletWasabi.Fluent.Desktop/Program.cs
WalletWasabi.Fluent.Desktop/Program.cs
@@ -2,14 +2,12 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Dialogs;
using Avalonia.ReactiveUI;
-using Avalonia.Threading;
using Splat;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using WalletWasabi.Fluent.Helpers;
-using WalletWasabi.Fluent.ViewModels;
using WalletWasabi.Gui;
using WalletWasabi.Gui.CommandLine;
using WalletWasabi.Gui.CrashReport;
@@ -26,9 +24,9 @@ namespace WalletWasabi.Fluent.Desktop
private static Global? Global;
// This is only needed to pass CrashReporter to AppMainAsync otherwise it could be a local variable in Main().
- private static CrashReporter CrashReporter = new CrashReporter();
+ private static readonly CrashReporter CrashReporter = new CrashReporter();
- private static TerminateService TerminateService = new TerminateService(TerminateApplicationAsync);
+ private static readonly TerminateService TerminateService = new TerminateService(TerminateApplicationAsync);
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
@@ -41,10 +39,10 @@ namespace WalletWasabi.Fluent.Desktop
try
{
Global = CreateGlobal();
+
+ // TODO only required due to statusbar vm... to be removed.
Locator.CurrentMutable.RegisterConstant(Global);
- Locator.CurrentMutable.RegisterConstant(CrashReporter);
- //Platform.BaseDirectory = Path.Combine(Global.DataDir, "Gui");
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
@@ -61,11 +59,7 @@ namespace WalletWasabi.Fluent.Desktop
Logger.LogSoftwareStarted("Wasabi GUI");
BuildAvaloniaApp()
- .AfterSetup(_ =>
- {
- ThemeHelper.ApplyTheme(Global!.UiConfig.DarkModeEnabled);
- AppMainAsync(args);
- })
+ .AfterSetup(_ => ThemeHelper.ApplyTheme(Global!.UiConfig.DarkModeEnabled))
.StartWithClassicDesktopLifetime(args);
}
}
@@ -106,23 +100,6 @@ namespace WalletWasabi.Fluent.Desktop
return executionTask.GetAwaiter().GetResult();
}
- private static async void AppMainAsync(string[] args)
- {
- try
- {
- await Global!.InitializeNoWalletAsync(TerminateService);
-
- MainViewModel.Instance!.Initialize();
-
- Dispatcher.UIThread.Post(GC.Collect);
- }
- catch (Exception ex)
- {
- // There is no other way to stop the creation of the WasabiWindow, we have to exit the application here instead of return to Main.
- TerminateAppAndHandleException(ex, true);
- }
- }
-
/// <summary>
/// This is a helper method until the creation of the window in AppMainAsync cannot be aborted without Environment.Exit().
/// </summary>
@@ -198,7 +175,7 @@ namespace WalletWasabi.Fluent.Desktop
{
bool useGpuLinux = true;
- var result = AppBuilder.Configure(() => new App(Global!))
+ var result = AppBuilder.Configure(() => new App(Global!, async () => await Global!.InitializeNoWalletAsync(TerminateService)))
.UseReactiveUI();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))

MODIFY
WalletWasabi.Fluent/App.xaml.cs
WalletWasabi.Fluent/App.xaml.cs
+using System;
+using System.Reactive.Concurrency;
+using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
+using ReactiveUI;
using WalletWasabi.Fluent.Behaviors;
using WalletWasabi.Fluent.ViewModels;
using WalletWasabi.Fluent.Views;
@@ -11,16 +15,18 @@ namespace WalletWasabi.Fluent
{
public class App : Application
{
- private Global? _global;
+ private readonly Global? _global;
+ private Func<Task> _backendInitialiseAsync;
public App()
{
Name = "Wasabi Wallet";
}
- public App(Global global) : this()
+ public App(Global global, Func<Task> backendInitialiseAsync) : this()
{
_global = global;
+ _backendInitialiseAsync = backendInitialiseAsync;
}
public override void Initialize()
@@ -42,6 +48,14 @@ namespace WalletWasabi.Fluent
{
DataContext = MainViewModel.Instance
};
+
+ RxApp.MainThreadScheduler.Schedule(
+ async () =>
+ {
+ await _backendInitialiseAsync();
+
+ MainViewModel.Instance!.Initialize();
+ });
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -109,15 +109,6 @@ namespace WalletWasabi.Fluent.ViewModels
public void Initialize()
{
- // Temporary to keep things running without VM modifications.
- MainWindowViewModel.Instance = new MainWindowViewModel(
- _global.Network,
- _global.UiConfig,
- _global.WalletManager,
- null!,
- null!,
- false);
-
StatusBar.Initialize(_global.Nodes.ConnectedNodes);
if (Network != Network.Main)

remove initialisation of legacy stuff from old ui project.