1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 18:23:32 +00:00

UI - Try to die a bit more gracefully

This commit is contained in:
RobertBeekman 2024-03-10 22:07:04 +01:00
parent 1cbf6587a1
commit d7c776323c

View File

@ -19,6 +19,7 @@ using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Threading; using Avalonia.Threading;
using ReactiveUI; using ReactiveUI;
using Serilog;
namespace Artemis.UI.Screens.Root; namespace Artemis.UI.Screens.Root;
@ -28,13 +29,15 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
private readonly IDebugService _debugService; private readonly IDebugService _debugService;
private readonly DefaultTitleBarViewModel _defaultTitleBarViewModel; private readonly DefaultTitleBarViewModel _defaultTitleBarViewModel;
private readonly IClassicDesktopStyleApplicationLifetime _lifeTime; private readonly IClassicDesktopStyleApplicationLifetime _lifeTime;
private readonly ILogger _logger;
private readonly IRouter _router; private readonly IRouter _router;
private readonly ISettingsService _settingsService; private readonly ISettingsService _settingsService;
private readonly IUpdateService _updateService; private readonly IUpdateService _updateService;
private readonly IWindowService _windowService; private readonly IWindowService _windowService;
private readonly ObservableAsPropertyHelper<ViewModelBase?> _titleBarViewModel; private readonly ObservableAsPropertyHelper<ViewModelBase?> _titleBarViewModel;
public RootViewModel(IRouter router, public RootViewModel(ILogger logger,
IRouter router,
ICoreService coreService, ICoreService coreService,
ISettingsService settingsService, ISettingsService settingsService,
IRegistrationService registrationService, IRegistrationService registrationService,
@ -50,6 +53,7 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
WindowSizeSetting = settingsService.GetSetting<WindowSize?>("WindowSize"); WindowSizeSetting = settingsService.GetSetting<WindowSize?>("WindowSize");
SidebarViewModel = sidebarViewModel; SidebarViewModel = sidebarViewModel;
_logger = logger;
_router = router; _router = router;
_coreService = coreService; _coreService = coreService;
_settingsService = settingsService; _settingsService = settingsService;
@ -80,6 +84,8 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
} }
Task.Run(() => Task.Run(() =>
{
try
{ {
// Before doing heavy lifting, initialize the update service which may prompt a restart // Before doing heavy lifting, initialize the update service which may prompt a restart
// Only initialize with an update check if we're not going to show the UI // Only initialize with an update check if we're not going to show the UI
@ -94,6 +100,12 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
registrationService.RegisterBuiltInDataModelDisplays(); registrationService.RegisterBuiltInDataModelDisplays();
registrationService.RegisterBuiltInDataModelInputs(); registrationService.RegisterBuiltInDataModelInputs();
registrationService.RegisterBuiltInPropertyEditors(); registrationService.RegisterBuiltInPropertyEditors();
}
catch (Exception e)
{
_logger.Fatal(e, "Error during initialization");
_windowService.ShowExceptionDialog("Fatal error occured during initialization", e);
}
}); });
} }