mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Profiles - Added workshop installing
This commit is contained in:
1 parent
4143cc2de8
commit
671c587df6
21 files changed
+401
-73
No files matched your search
@@ -77,16 +77,16 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
Observable.FromEventPattern<ProfileConfigurationEventArgs>(x => profileCategory.ProfileConfigurationRemoved += x, x => profileCategory.ProfileConfigurationRemoved -= x)
|
||||
.Subscribe(e => profileConfigurations.RemoveMany(profileConfigurations.Items.Where(c => c == e.EventArgs.ProfileConfiguration)))
|
||||
.DisposeWith(d);
|
||||
|
||||
profileConfigurations.Edit(updater =>
|
||||
{
|
||||
updater.Clear();
|
||||
updater.AddRange(profileCategory.ProfileConfigurations);
|
||||
});
|
||||
|
||||
_isCollapsed = ProfileCategory.WhenAnyValue(vm => vm.IsCollapsed).ToProperty(this, vm => vm.IsCollapsed).DisposeWith(d);
|
||||
_isSuspended = ProfileCategory.WhenAnyValue(vm => vm.IsSuspended).ToProperty(this, vm => vm.IsSuspended).DisposeWith(d);
|
||||
});
|
||||
|
||||
profileConfigurations.Edit(updater =>
|
||||
{
|
||||
foreach (ProfileConfiguration profileConfiguration in profileCategory.ProfileConfigurations)
|
||||
updater.Add(profileConfiguration);
|
||||
});
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> ImportProfile { get; }
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
x:DataType="home:WorkshopHomeViewModel">
|
||||
<Border Classes="router-container">
|
||||
<Grid RowDefinitions="200,*,*">
|
||||
<ProgressBar ZIndex="999" IsIndeterminate="True" IsVisible="{CompiledBinding !WorkshopReachable}" Grid.Row="0" VerticalAlignment="Top"></ProgressBar>
|
||||
|
||||
<Image Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
VerticalAlignment="Top"
|
||||
@@ -36,9 +38,9 @@
|
||||
<DropShadowEffect Color="Black" OffsetX="2" OffsetY="2" BlurRadius="5"></DropShadowEffect>
|
||||
</TextBlock.Effect>
|
||||
</TextBlock>
|
||||
|
||||
|
||||
<StackPanel Margin="30 -75 30 0" Grid.Row="1">
|
||||
<StackPanel Spacing="10" Orientation="Horizontal" VerticalAlignment="Top">
|
||||
<StackPanel Spacing="10" Orientation="Horizontal" VerticalAlignment="Top">
|
||||
<Button Width="150" Height="180" Command="{CompiledBinding AddSubmission}" VerticalContentAlignment="Top">
|
||||
<StackPanel>
|
||||
<avalonia:MaterialIcon Kind="CloudUpload" HorizontalAlignment="Left" Width="60" Height="60" Margin="0 5" />
|
||||
@@ -46,7 +48,7 @@
|
||||
<TextBlock TextWrapping="Wrap" FontSize="12" Opacity="0.8">Upload your own creations to the workshop!</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
|
||||
<Button Width="150" Height="180" Command="{CompiledBinding Navigate}" CommandParameter="workshop/profiles/1" VerticalContentAlignment="Top">
|
||||
<StackPanel>
|
||||
<avalonia:MaterialIcon Kind="FolderVideo" HorizontalAlignment="Left" Width="60" Height="60" Margin="0 5" />
|
||||
@@ -62,17 +64,16 @@
|
||||
<TextBlock TextWrapping="Wrap" FontSize="12" Opacity="0.8">Layouts make your devices look great in the editor.</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
|
||||
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<TextBlock Classes="h4" Margin="0 15 0 5">Featured submissions</TextBlock>
|
||||
<TextBlock>Not yet implemented, here we'll show submissions we think are worth some extra attention.</TextBlock>
|
||||
|
||||
|
||||
<TextBlock Classes="h4" Margin="0 15 0 5">Recently updated</TextBlock>
|
||||
<TextBlock>Not yet implemented, here we'll a few of the most recent uploads/updates to the workshop.</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Screens.Workshop.SubmissionWizard;
|
||||
@@ -6,6 +7,8 @@ using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Home;
|
||||
@@ -13,21 +16,38 @@ namespace Artemis.UI.Screens.Workshop.Home;
|
||||
public class WorkshopHomeViewModel : ActivatableViewModelBase, IWorkshopViewModel
|
||||
{
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private bool _workshopReachable;
|
||||
|
||||
public WorkshopHomeViewModel(IRouter router, IWindowService windowService)
|
||||
public WorkshopHomeViewModel(IRouter router, IWindowService windowService, IWorkshopService workshopService)
|
||||
{
|
||||
_windowService = windowService;
|
||||
AddSubmission = ReactiveCommand.CreateFromTask(ExecuteAddSubmission);
|
||||
Navigate = ReactiveCommand.CreateFromTask<string>(async r => await router.Navigate(r));
|
||||
_workshopService = workshopService;
|
||||
|
||||
AddSubmission = ReactiveCommand.CreateFromTask(ExecuteAddSubmission, this.WhenAnyValue(vm => vm.WorkshopReachable));
|
||||
Navigate = ReactiveCommand.CreateFromTask<string>(async r => await router.Navigate(r), this.WhenAnyValue(vm => vm.WorkshopReachable));
|
||||
|
||||
this.WhenActivated((CompositeDisposable _) => Dispatcher.UIThread.InvokeAsync(ValidateWorkshopStatus));
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> AddSubmission { get; }
|
||||
public ReactiveCommand<string, Unit> Navigate { get; }
|
||||
|
||||
public bool WorkshopReachable
|
||||
{
|
||||
get => _workshopReachable;
|
||||
private set => RaiseAndSetIfChanged(ref _workshopReachable, value);
|
||||
}
|
||||
|
||||
private async Task ExecuteAddSubmission(CancellationToken arg)
|
||||
{
|
||||
await _windowService.ShowDialogAsync<SubmissionWizardViewModel, bool>();
|
||||
}
|
||||
|
||||
private async Task ValidateWorkshopStatus()
|
||||
{
|
||||
WorkshopReachable = await _workshopService.ValidateWorkshopStatus();
|
||||
}
|
||||
|
||||
public EntryType? EntryType => null;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:home="clr-namespace:Artemis.UI.Screens.Workshop.Home"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="550"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Home.WorkshopOfflineView"
|
||||
x:DataType="home:WorkshopOfflineViewModel">
|
||||
<Border Classes="router-container">
|
||||
<Panel>
|
||||
<ProgressBar ZIndex="999" IsIndeterminate="True" IsVisible="{CompiledBinding Retry.IsExecuting^}" VerticalAlignment="Top"></ProgressBar>
|
||||
|
||||
<StackPanel Margin="0 75 0 0">
|
||||
<StackPanel.Styles>
|
||||
<Styles>
|
||||
<Style Selector="TextBlock">
|
||||
<Setter Property="TextAlignment" Value="Center"></Setter>
|
||||
<Setter Property="TextWrapping" Value="Wrap"></Setter>
|
||||
</Style>
|
||||
</Styles>
|
||||
</StackPanel.Styles>
|
||||
|
||||
<TextBlock Theme="{StaticResource TitleTextBlockStyle}">Could not reach the workshop</TextBlock>
|
||||
<TextBlock Text="{CompiledBinding Message}" MaxWidth="600" Classes="subtitle"/>
|
||||
<avalonia:MaterialIcon Kind="LanDisconnect" Width="120" Height="120" Margin="0 60"></avalonia:MaterialIcon>
|
||||
|
||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Please ensure you are connected to the internet.</TextBlock>
|
||||
<TextBlock Margin="0 10" Classes="subtitle">If this keeps occuring, hit us up on Discord</TextBlock>
|
||||
|
||||
<Button HorizontalAlignment="Center" Margin="0 20" Command="{CompiledBinding Retry}">Retry</Button>
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,14 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Home;
|
||||
|
||||
public partial class WorkshopOfflineView : ReactiveUserControl<WorkshopOfflineViewModel>
|
||||
{
|
||||
public WorkshopOfflineView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Net;
|
||||
using System.Reactive;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Home;
|
||||
|
||||
public class WorkshopOfflineViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopOfflineParameters>, IWorkshopViewModel
|
||||
{
|
||||
private readonly IRouter _router;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private string _message;
|
||||
|
||||
/// <inheritdoc />
|
||||
public WorkshopOfflineViewModel(IWorkshopService workshopService, IRouter router)
|
||||
{
|
||||
_workshopService = workshopService;
|
||||
_router = router;
|
||||
|
||||
Retry = ReactiveCommand.CreateFromTask(ExecuteRetry);
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> Retry { get; }
|
||||
|
||||
public string Message
|
||||
{
|
||||
get => _message;
|
||||
set => RaiseAndSetIfChanged(ref _message, value);
|
||||
}
|
||||
|
||||
public override Task OnNavigating(WorkshopOfflineParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
Message = parameters.Message;
|
||||
return base.OnNavigating(parameters, args, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task ExecuteRetry(CancellationToken cancellationToken)
|
||||
{
|
||||
IWorkshopService.WorkshopStatus status = await _workshopService.GetWorkshopStatus();
|
||||
if (status.IsReachable)
|
||||
await _router.Navigate("workshop");
|
||||
|
||||
Message = status.Message;
|
||||
}
|
||||
|
||||
public EntryType? EntryType => null;
|
||||
}
|
||||
|
||||
public class WorkshopOfflineParameters
|
||||
{
|
||||
public string Message { get; set; }
|
||||
}
|
||||
@@ -86,29 +86,36 @@
|
||||
<StackPanel>
|
||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Latest release</TextBlock>
|
||||
<Border Classes="card-separator" />
|
||||
<Button CornerRadius="8"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch">
|
||||
<Button CornerRadius="8"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Command="{CompiledBinding DownloadLatestRelease}">
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<!-- Icon -->
|
||||
<Border Grid.Column="0"
|
||||
CornerRadius="8"
|
||||
CornerRadius="4"
|
||||
Background="{StaticResource SystemAccentColor}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 6"
|
||||
Width="45"
|
||||
Height="45"
|
||||
Width="50"
|
||||
Height="50"
|
||||
ClipToBounds="True">
|
||||
<avalonia:MaterialIcon Kind="Download"></avalonia:MaterialIcon>
|
||||
</Border>
|
||||
|
||||
<!-- Body -->
|
||||
<StackPanel Grid.Column="1" Margin="10 6">
|
||||
<StackPanel Grid.Column="1" Margin="10 0" VerticalAlignment="Center">
|
||||
<TextBlock Text="{CompiledBinding Entry.LatestRelease.Version, FallbackValue=Version}"></TextBlock>
|
||||
<TextBlock Classes="subtitle">
|
||||
<avalonia:MaterialIcon Kind="BoxOutline" />
|
||||
<Run Text="{CompiledBinding Entry.LatestRelease.DownloadSize, Converter={StaticResource BytesToStringConverter}, Mode=OneWay}"></Run>
|
||||
</TextBlock>
|
||||
<TextBlock Classes="subtitle"
|
||||
ToolTip.Tip="{CompiledBinding Entry.LatestRelease.CreatedAt, Converter={StaticResource DateTimeConverter}}">
|
||||
<avalonia:MaterialIcon Kind="Calendar" />
|
||||
<Run>Created</Run>
|
||||
<Run Text="{CompiledBinding Entry.LatestRelease.CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Button>
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Screens.Workshop.Parameters;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.DownloadHandlers;
|
||||
using Artemis.WebClient.Workshop.DownloadHandlers.Implementations;
|
||||
using ReactiveUI;
|
||||
using StrawberryShake;
|
||||
|
||||
@@ -14,18 +21,24 @@ namespace Artemis.UI.Screens.Workshop.Profile;
|
||||
public class ProfileDetailsViewModel : RoutableScreen<ActivatableViewModelBase, WorkshopDetailParameters>, IWorkshopViewModel
|
||||
{
|
||||
private readonly IWorkshopClient _client;
|
||||
private readonly ProfileEntryDownloadHandler _downloadHandler;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly ObservableAsPropertyHelper<DateTimeOffset?> _updatedAt;
|
||||
private IGetEntryById_Entry? _entry;
|
||||
|
||||
public ProfileDetailsViewModel(IWorkshopClient client)
|
||||
public ProfileDetailsViewModel(IWorkshopClient client, ProfileEntryDownloadHandler downloadHandler, INotificationService notificationService)
|
||||
{
|
||||
_client = client;
|
||||
_downloadHandler = downloadHandler;
|
||||
_notificationService = notificationService;
|
||||
_updatedAt = this.WhenAnyValue(vm => vm.Entry).Select(e => e?.LatestRelease?.CreatedAt ?? e?.CreatedAt).ToProperty(this, vm => vm.UpdatedAt);
|
||||
|
||||
DownloadLatestRelease = ReactiveCommand.CreateFromTask(ExecuteDownloadLatestRelease);
|
||||
}
|
||||
|
||||
public DateTimeOffset? UpdatedAt => _updatedAt.Value;
|
||||
public ReactiveCommand<Unit, Unit> DownloadLatestRelease { get; }
|
||||
|
||||
public EntryType? EntryType => null;
|
||||
public DateTimeOffset? UpdatedAt => _updatedAt.Value;
|
||||
|
||||
public IGetEntryById_Entry? Entry
|
||||
{
|
||||
@@ -43,7 +56,21 @@ public class ProfileDetailsViewModel : RoutableScreen<ActivatableViewModelBase,
|
||||
IOperationResult<IGetEntryByIdResult> result = await _client.GetEntryById.ExecuteAsync(entryId, cancellationToken);
|
||||
if (result.IsErrorResult())
|
||||
return;
|
||||
|
||||
|
||||
Entry = result.Data?.Entry;
|
||||
}
|
||||
|
||||
private async Task ExecuteDownloadLatestRelease(CancellationToken cancellationToken)
|
||||
{
|
||||
if (Entry?.LatestRelease == null)
|
||||
return;
|
||||
|
||||
EntryInstallResult<ProfileConfiguration> result = await _downloadHandler.InstallProfileAsync(Entry.LatestRelease.Id, new Progress<StreamProgress>(), cancellationToken);
|
||||
if (result.IsSuccess)
|
||||
_notificationService.CreateNotification().WithTitle("Profile installed").WithSeverity(NotificationSeverity.Success).Show();
|
||||
else
|
||||
_notificationService.CreateNotification().WithTitle("Failed to install profile").WithMessage(result.Message).WithSeverity(NotificationSeverity.Error).Show();
|
||||
}
|
||||
|
||||
public EntryType? EntryType => null;
|
||||
}
|
||||
@@ -3,10 +3,10 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:steps="clr-namespace:Artemis.UI.Screens.Workshop.SubmissionWizard.Steps"
|
||||
mc:Ignorable="d" d:DesignWidth="970" d:DesignHeight="900"
|
||||
mc:Ignorable="d" d:DesignWidth="970" d:DesignHeight="900"
|
||||
x:Class="Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.UploadStepView"
|
||||
x:DataType="steps:UploadStepViewModel">
|
||||
<StackPanel Margin="0 50 0 0" >
|
||||
<StackPanel Margin="0 50 0 0">
|
||||
<StackPanel.Styles>
|
||||
<Styles>
|
||||
<Style Selector="TextBlock">
|
||||
@@ -15,23 +15,31 @@
|
||||
</Style>
|
||||
</Styles>
|
||||
</StackPanel.Styles>
|
||||
<TextBlock Theme="{StaticResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap">
|
||||
|
||||
<TextBlock IsVisible="{CompiledBinding !Finished}" Theme="{StaticResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap">
|
||||
Uploading your submission...
|
||||
</TextBlock>
|
||||
<TextBlock TextAlignment="Center" TextWrapping="Wrap">
|
||||
Wooo, the final step, that was pretty easy, right!?
|
||||
</TextBlock>
|
||||
|
||||
<ProgressBar Margin="0 15 0 0"
|
||||
Width="380"
|
||||
IsVisible="{CompiledBinding !Finished}"
|
||||
IsIndeterminate="{CompiledBinding ProgressIndeterminate}"
|
||||
Value="{CompiledBinding ProgressPercentage}"></ProgressBar>
|
||||
|
||||
<StackPanel IsVisible="{CompiledBinding Finished}" Margin="0 100 0 0">
|
||||
<Lottie Path="/Assets/Animations/success.json" RepeatCount="1" Width="300" Height="300"></Lottie>
|
||||
<ProgressBar IsVisible="{CompiledBinding !Finished}"
|
||||
Margin="0 15 0 0"
|
||||
Width="380"
|
||||
IsIndeterminate="{CompiledBinding ProgressIndeterminate}"
|
||||
Value="{CompiledBinding ProgressPercentage}">
|
||||
</ProgressBar>
|
||||
|
||||
<StackPanel IsVisible="{CompiledBinding Succeeded}">
|
||||
<Lottie Path="/Assets/Animations/success.json" RepeatCount="1" Width="250" Height="250" Margin="0 100"></Lottie>
|
||||
<TextBlock Theme="{StaticResource TitleTextBlockStyle}">All done! Hit finish to view your submission.</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<StackPanel IsVisible="{CompiledBinding Failed}">
|
||||
<TextBlock FontSize="140" Margin="0 100">😢</TextBlock>
|
||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">
|
||||
Unfortunately something went wrong while uploading your submission.
|
||||
</TextBlock>
|
||||
<TextBlock>Hit finish to view your submission, from there you can try to upload a new release.</TextBlock>
|
||||
<TextBlock Margin="0 10" Classes="subtitle">If this keeps occuring, hit us up on Discord</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -28,8 +28,10 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
private readonly ObservableAsPropertyHelper<int> _progressPercentage;
|
||||
private readonly ObservableAsPropertyHelper<bool> _progressIndeterminate;
|
||||
|
||||
private bool _finished;
|
||||
private Guid? _entryId;
|
||||
private bool _finished;
|
||||
private bool _succeeded;
|
||||
private bool _failed;
|
||||
|
||||
/// <inheritdoc />
|
||||
public UploadStepViewModel(IWorkshopClient workshopClient, IWorkshopService workshopService, EntryUploadHandlerFactory entryUploadHandlerFactory, IWindowService windowService, IRouter router)
|
||||
@@ -43,14 +45,14 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
ShowGoBack = false;
|
||||
ContinueText = "Finish";
|
||||
Continue = ReactiveCommand.CreateFromTask(ExecuteContinue, this.WhenAnyValue(vm => vm.Finished));
|
||||
|
||||
|
||||
_progressPercentage = Observable.FromEventPattern<StreamProgress>(x => _progress.ProgressChanged += x, x => _progress.ProgressChanged -= x)
|
||||
.Select(e => e.EventArgs.ProgressPercentage)
|
||||
.ToProperty(this, vm => vm.ProgressPercentage);
|
||||
_progressIndeterminate = Observable.FromEventPattern<StreamProgress>(x => _progress.ProgressChanged += x, x => _progress.ProgressChanged -= x)
|
||||
.Select(e => e.EventArgs.ProgressPercentage == 0)
|
||||
.ToProperty(this, vm => vm.ProgressIndeterminate);
|
||||
|
||||
|
||||
this.WhenActivated(d => Observable.FromAsync(ExecuteUpload).Subscribe().DisposeWith(d));
|
||||
}
|
||||
|
||||
@@ -69,6 +71,18 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
set => RaiseAndSetIfChanged(ref _finished, value);
|
||||
}
|
||||
|
||||
public bool Succeeded
|
||||
{
|
||||
get => _succeeded;
|
||||
set => RaiseAndSetIfChanged(ref _succeeded, value);
|
||||
}
|
||||
|
||||
public bool Failed
|
||||
{
|
||||
get => _failed;
|
||||
set => RaiseAndSetIfChanged(ref _failed, value);
|
||||
}
|
||||
|
||||
public async Task ExecuteUpload(CancellationToken cancellationToken)
|
||||
{
|
||||
IOperationResult<IAddEntryResult> result = await _workshopClient.AddEntry.ExecuteAsync(new CreateEntryInput
|
||||
@@ -85,12 +99,13 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
if (result.IsErrorResult() || entryId == null)
|
||||
{
|
||||
await _windowService.ShowConfirmContentDialog("Failed to create workshop entry", result.Errors.ToString() ?? "Not even an error message", "Close", null);
|
||||
State.ChangeScreen<SubmitStepViewModel>();
|
||||
return;
|
||||
}
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
|
||||
// Upload image
|
||||
if (State.Icon != null)
|
||||
await _workshopService.SetEntryIcon(entryId.Value, _progress, State.Icon, cancellationToken);
|
||||
@@ -113,21 +128,27 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
}
|
||||
|
||||
_entryId = entryId;
|
||||
Finished = true;
|
||||
Succeeded = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Something went wrong when creating a release :c
|
||||
// We'll keep the workshop entry so that the user can make changes and try again
|
||||
Failed = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Finished = true;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExecuteContinue()
|
||||
{
|
||||
State.Finish();
|
||||
|
||||
if (_entryId == null)
|
||||
return;
|
||||
|
||||
State.Finish();
|
||||
switch (State.EntryType)
|
||||
{
|
||||
case EntryType.Layout:
|
||||
|
||||
Reference in new issue
Block a user