Core - Fixed crash on startup if workshop folder is missing

Updating - Properly delay auto-update check until the UI shows,
This commit is contained in:
Robert committed 2024-02-17 15:01:18 +01:00
1 parent cf10193bd2
commit 0b6bf5685e
9 files changed
+58 -32

No files matched your search

+10 -8
View File
@@ -62,7 +62,6 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
router.SetRoot(this);
mainWindowService.ConfigureMainWindowProvider(this);
DisplayAccordingToSettings();
OpenScreen = ReactiveCommand.Create<string?>(ExecuteOpenScreen);
OpenDebugger = ReactiveCommand.CreateFromTask(ExecuteOpenDebugger);
Exit = ReactiveCommand.CreateFromTask(ExecuteExit);
@@ -74,10 +73,17 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
.Select(vm => vm ?? _defaultTitleBarViewModel)
.ToProperty(this, vm => vm.TitleBarViewModel);
if (ShouldShowUI())
{
ShowSplashScreen();
_coreService.Initialized += (_, _) => Dispatcher.UIThread.InvokeAsync(OpenMainWindow);
}
Task.Run(() =>
{
// Before doing heavy lifting, initialize the update service which may prompt a restart
if (_updateService.Initialize())
// Only initialize with an update check if we're not going to show the UI
if (_updateService.Initialize(!ShouldShowUI()))
return;
// Workshop service goes first so it has a chance to clean up old workshop entries and introduce new ones
@@ -118,17 +124,13 @@ public class RootViewModel : RoutableHostScreen<RoutableScreen>, IMainWindowProv
OnMainWindowClosed();
}
private void DisplayAccordingToSettings()
private bool ShouldShowUI()
{
bool autoRunning = Constants.StartupArguments.Contains("--autorun");
bool minimized = Constants.StartupArguments.Contains("--minimized");
bool showOnAutoRun = _settingsService.GetSetting("UI.ShowOnStartup", true).Value;
if ((autoRunning && !showOnAutoRun) || minimized)
return;
ShowSplashScreen();
_coreService.Initialized += (_, _) => Dispatcher.UIThread.InvokeAsync(OpenMainWindow);
return (autoRunning && showOnAutoRun) || !minimized;
}
private void ShowSplashScreen()
@@ -87,7 +87,7 @@ public partial class ReleaseDetailsViewModel : RoutableScreen<ReleaseDetailsView
private void ExecuteRestart()
{
_updateService.RestartForUpdate(false);
_updateService.RestartForUpdate("ReleaseDetails", false);
}
private async Task ExecuteInstall(CancellationToken cancellationToken)
@@ -17,7 +17,7 @@
<TextBlock Grid.Row="1" Grid.Column="0" Text="{CompiledBinding Release.CreatedAt, Converter={StaticResource DateTimeConverter}}" VerticalAlignment="Center" Classes="subtitle" FontSize="13" />
<avalonia:MaterialIcon Classes="status-icon" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Kind="CheckCircle" ToolTip.Tip="Current version"
IsVisible="{CompiledBinding IsCurrentVersion}" />
<avalonia:MaterialIcon Classes="status-icon" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Kind="History" ToolTip.Tip="Previous version"
<avalonia:MaterialIcon Classes="status-icon" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Kind="History" ToolTip.Tip="Last previously installed version"
IsVisible="{CompiledBinding IsPreviousVersion}" />
</Grid>
<StackPanel Margin="4" IsVisible="{CompiledBinding !ShowStatusIndicator}">