diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index bddd938b2..c53778340 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -35,4 +35,11 @@ + + + + WorkshopUnreachableStepView.axaml + Code + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/StartupWizard/StartupWizardView.axaml b/src/Artemis.UI/Screens/StartupWizard/StartupWizardView.axaml index c83c28447..b3c179d71 100644 --- a/src/Artemis.UI/Screens/StartupWizard/StartupWizardView.axaml +++ b/src/Artemis.UI/Screens/StartupWizard/StartupWizardView.axaml @@ -14,13 +14,13 @@ Width="1050" Height="735" WindowStartupLocation="CenterOwner"> - - + + + Artemis 2 - @@ -32,13 +32,11 @@ - - - - + + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/StartupWizard/Steps/DefaultEntriesStepView.axaml b/src/Artemis.UI/Screens/StartupWizard/Steps/DefaultEntriesStepView.axaml index 55ef5da1b..115668100 100644 --- a/src/Artemis.UI/Screens/StartupWizard/Steps/DefaultEntriesStepView.axaml +++ b/src/Artemis.UI/Screens/StartupWizard/Steps/DefaultEntriesStepView.axaml @@ -13,8 +13,10 @@ Below is a list of default features that can be installed to get you started with Artemis. You can always install or uninstall features later via the Workshop. - - + + + Fetching default features from the Artemis workshop... + @@ -58,9 +60,10 @@ Currently installing - - - + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/StartupWizard/Steps/DefaultEntriesStepViewModel.cs b/src/Artemis.UI/Screens/StartupWizard/Steps/DefaultEntriesStepViewModel.cs index 073a797ad..04574c615 100644 --- a/src/Artemis.UI/Screens/StartupWizard/Steps/DefaultEntriesStepViewModel.cs +++ b/src/Artemis.UI/Screens/StartupWizard/Steps/DefaultEntriesStepViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using System.Reactive.Linq; using System.Threading; using System.Threading.Tasks; using Artemis.Core.Services; @@ -18,8 +19,7 @@ namespace Artemis.UI.Screens.StartupWizard.Steps; public partial class DefaultEntriesStepViewModel : WizardStepViewModel { - [Notify] private bool _workshopReachable; - [Notify] private bool _fetchingDefaultEntries; + [Notify] private bool _fetchingDefaultEntries = true; [Notify] private int _installedEntries; [Notify] private int _totalEntries = 1; [Notify] private DefaultEntryItemViewModel? _currentEntry; @@ -44,16 +44,16 @@ public partial class DefaultEntriesStepViewModel : WizardStepViewModel { await Install(ct); ExecuteContinue(); - }); + }, this.WhenAnyValue(vm => vm.FetchingDefaultEntries).Select(b => !b)); GoBack = ReactiveCommand.Create(() => Wizard.ChangeScreen()); this.WhenActivatedAsync(async d => { - WorkshopReachable = await workshopService.ValidateWorkshopStatus(d.AsCancellationToken()); - if (WorkshopReachable) - { + CancellationToken ct = d.AsCancellationToken(); + if (await workshopService.ValidateWorkshopStatus(false, ct)) await GetDefaultEntries(d.AsCancellationToken()); - } + else if (!ct.IsCancellationRequested) + Wizard.ChangeScreen(); }); } @@ -95,9 +95,6 @@ public partial class DefaultEntriesStepViewModel : WizardStepViewModel private async Task GetDefaultEntries(CancellationToken cancellationToken) { - if (!WorkshopReachable) - return; - FetchingDefaultEntries = true; IOperationResult result = await _client.GetDefaultEntries.ExecuteAsync(100, null, cancellationToken); diff --git a/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepView.axaml b/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepView.axaml new file mode 100644 index 000000000..64fb3ca08 --- /dev/null +++ b/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepView.axaml @@ -0,0 +1,30 @@ + + + + + + + + + Could not reach the workshop + This unfortunately means the setup wizard cannot continue. + + + Please ensure you are connected to the internet. + If this keeps occuring, hit us up on Discord + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepView.axaml.cs b/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepView.axaml.cs new file mode 100644 index 000000000..c4162a875 --- /dev/null +++ b/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepView.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; + +namespace Artemis.UI.Screens.StartupWizard.Steps; + +public partial class WorkshopUnreachableStepView : ReactiveUserControl +{ + public WorkshopUnreachableStepView() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepViewModel.cs b/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepViewModel.cs new file mode 100644 index 000000000..d7dc1f617 --- /dev/null +++ b/src/Artemis.UI/Screens/StartupWizard/Steps/WorkshopUnreachableStepViewModel.cs @@ -0,0 +1,19 @@ +namespace Artemis.UI.Screens.StartupWizard.Steps; + +public class WorkshopUnreachableStepViewModel : WizardStepViewModel +{ + public WorkshopUnreachableStepViewModel() + { + HideAllButtons = true; + } + + public void Retry() + { + Wizard.ChangeScreen(); + } + + public void Skip() + { + Wizard.Close(false); + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/StartupWizard/WizardStepViewModel.cs b/src/Artemis.UI/Screens/StartupWizard/WizardStepViewModel.cs index 83ebe2172..76ba4c9f9 100644 --- a/src/Artemis.UI/Screens/StartupWizard/WizardStepViewModel.cs +++ b/src/Artemis.UI/Screens/StartupWizard/WizardStepViewModel.cs @@ -15,6 +15,7 @@ public abstract partial class WizardStepViewModel : ValidatableViewModelBase [Notify] private bool _showFinish; [Notify] private bool _showGoBack = true; [Notify] private bool _showHeader = true; + [Notify] private bool _hideAllButtons; public StartupWizardViewModel Wizard { get; set; } = null!; } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Workshop/Home/WorkshopHomeViewModel.cs b/src/Artemis.UI/Screens/Workshop/Home/WorkshopHomeViewModel.cs index 7fd2bb675..3ab39b11b 100644 --- a/src/Artemis.UI/Screens/Workshop/Home/WorkshopHomeViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Home/WorkshopHomeViewModel.cs @@ -41,7 +41,7 @@ public partial class WorkshopHomeViewModel : RoutableScreen this.WhenActivatedAsync(async d => { - WorkshopReachable = await workshopService.ValidateWorkshopStatus(d.AsCancellationToken()); + WorkshopReachable = await workshopService.ValidateWorkshopStatus(true, d.AsCancellationToken()); IOperationResult popularResult = await client.GetPopularEntries.ExecuteAsync(); popular.Edit(p => diff --git a/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabViewModel.cs b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabViewModel.cs index caefeab1e..948c9f20f 100644 --- a/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/Library/Tabs/SubmissionsTabViewModel.cs @@ -63,7 +63,7 @@ public partial class SubmissionsTabViewModel : RoutableScreen this.WhenActivatedAsync(async d => { - WorkshopReachable = await workshopService.ValidateWorkshopStatus(d.AsCancellationToken()); + WorkshopReachable = await workshopService.ValidateWorkshopStatus(true, d.AsCancellationToken()); if (WorkshopReachable) await GetEntries(d.AsCancellationToken()); }); diff --git a/src/Artemis.WebClient.Workshop/Services/Interfaces/IWorkshopService.cs b/src/Artemis.WebClient.Workshop/Services/Interfaces/IWorkshopService.cs index 922ed3d0d..f6295a9ed 100644 --- a/src/Artemis.WebClient.Workshop/Services/Interfaces/IWorkshopService.cs +++ b/src/Artemis.WebClient.Workshop/Services/Interfaces/IWorkshopService.cs @@ -54,9 +54,10 @@ public interface IWorkshopService /// /// Validates the status of the workshop. /// + /// Whether to navigate to the offline page if the workshop is unreachable. /// The cancellation token. /// A boolean indicating whether the workshop is reachable. - Task ValidateWorkshopStatus(CancellationToken cancellationToken); + Task ValidateWorkshopStatus(bool navigateIfUnreachable, CancellationToken cancellationToken); /// /// Navigates to a specific entry. diff --git a/src/Artemis.WebClient.Workshop/Services/WorkshopService.cs b/src/Artemis.WebClient.Workshop/Services/WorkshopService.cs index 7fcf5f847..553eb5f18 100644 --- a/src/Artemis.WebClient.Workshop/Services/WorkshopService.cs +++ b/src/Artemis.WebClient.Workshop/Services/WorkshopService.cs @@ -130,10 +130,10 @@ public class WorkshopService : IWorkshopService } /// - public async Task ValidateWorkshopStatus(CancellationToken cancellationToken) + public async Task ValidateWorkshopStatus(bool navigateIfUnreachable, CancellationToken cancellationToken) { IWorkshopService.WorkshopStatus status = await GetWorkshopStatus(cancellationToken); - if (!status.IsReachable && !cancellationToken.IsCancellationRequested) + if (navigateIfUnreachable && !status.IsReachable && !cancellationToken.IsCancellationRequested) await _router.Navigate($"workshop/offline/{status.Message}"); return status.IsReachable; }