1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Startup wizard - Correctly remember wizard was compelted

Settings - Fix double navigation occuring when opening settings
Settings - Fix double navigation occuring when opening releases
This commit is contained in:
Robert 2025-02-16 11:15:52 +01:00
parent ff74376ca2
commit 3367280576
3 changed files with 16 additions and 15 deletions

View File

@ -2,6 +2,7 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.UI.Routing; using Artemis.UI.Routing;
@ -42,14 +43,11 @@ public partial class SettingsViewModel : RoutableHostScreen<RoutableScreen>, IMa
public ViewModelBase? TitleBarViewModel => null; public ViewModelBase? TitleBarViewModel => null;
/// <inheritdoc /> /// <inheritdoc />
public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken) public override Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
{ {
// Display tab change on navigate // Display tab change on navigate, if there is none forward to the first
SelectedTab = SettingTabs.FirstOrDefault(t => t.Matches(args.Path)); SelectedTab = SettingTabs.FirstOrDefault(t => t.Matches(args.Path)) ?? SettingTabs.FirstOrDefault();
return Task.CompletedTask;
// Always show a tab, if there is none forward to the first
if (SelectedTab == null)
await _router.Navigate(SettingTabs.First().Path);
} }
public void GoBack() public void GoBack()

View File

@ -62,7 +62,7 @@ public partial class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsVie
public ReadOnlyObservableCollection<ReleaseViewModel> ReleaseViewModels { get; } public ReadOnlyObservableCollection<ReleaseViewModel> ReleaseViewModels { get; }
public string Channel { get; } public string Channel { get; }
public async Task GetReleases(CancellationToken cancellationToken) public async Task GetReleases(CancellationToken cancellationToken)
{ {
try try
@ -97,7 +97,7 @@ public partial class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsVie
Loading = false; Loading = false;
} }
} }
/// <inheritdoc /> /// <inheritdoc />
public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken) public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
{ {
@ -109,10 +109,6 @@ public partial class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsVie
SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(vm => vm.Release.Id == releaseId); SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(vm => vm.Release.Id == releaseId);
// Otherwise forward to the last release // Otherwise forward to the last release
else else
{ SelectedReleaseViewModel = ReleaseViewModels.FirstOrDefault(r => r.IsCurrentVersion) ?? ReleaseViewModels.FirstOrDefault();
ReleaseViewModel? lastRelease = ReleaseViewModels.FirstOrDefault(r => r.IsCurrentVersion) ?? ReleaseViewModels.FirstOrDefault();
if (lastRelease != null)
await _router.Navigate($"settings/releases/{lastRelease.Release.Id}");
}
} }
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.Services;
using Artemis.UI.Screens.StartupWizard.Steps; using Artemis.UI.Screens.StartupWizard.Steps;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;
@ -11,11 +12,13 @@ namespace Artemis.UI.Screens.StartupWizard;
public partial class StartupWizardViewModel : DialogViewModelBase<bool> public partial class StartupWizardViewModel : DialogViewModelBase<bool>
{ {
private readonly IContainer _container; private readonly IContainer _container;
private readonly ISettingsService _settingsService;
[Notify] private WizardStepViewModel _screen; [Notify] private WizardStepViewModel _screen;
public StartupWizardViewModel(IContainer container, IWindowService windowService) public StartupWizardViewModel(IContainer container, IWindowService windowService, ISettingsService settingsService)
{ {
_container = container; _container = container;
_settingsService = settingsService;
_screen = _container.Resolve<WelcomeStepViewModel>(); _screen = _container.Resolve<WelcomeStepViewModel>();
_screen.Wizard = this; _screen.Wizard = this;
@ -41,6 +44,10 @@ public partial class StartupWizardViewModel : DialogViewModelBase<bool>
public void SkipOrFinishWizard() public void SkipOrFinishWizard()
{ {
PluginSetting<bool> setting = _settingsService.GetSetting("UI.SetupWizardCompleted", false);
setting.Value = true;
setting.Save();
Close(true); Close(true);
} }
} }