Merge branch 'development'

This commit is contained in:
RobertBeekman committed 2024-01-30 13:15:42 +01:00
commit 960991e77b
8 files changed
+51 -70

No files matched your search

@@ -1 +0,0 @@
{"v":"5.9.6","fr":29.9700012207031,"ip":0,"op":17.0000006924242,"w":1080,"h":1080,"nm":"dog","ddd":0,"assets":[{"id":"comp_0","nm":"1","fr":29.9700012207031,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":50,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[571.5,705,0],"ix":2,"l":2},"a":{"a":0,"k":[31.5,132,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":0,"s":[103,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":4,"s":[78,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":9,"s":[103,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":12,"s":[78,100,100]},{"t":17.0000006924242,"s":[103,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-206,132],[269,132]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0,0,0,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":22,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600.000024438501,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"ball Outlines","parent":3,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[26.5,35.867,0],"ix":2,"l":2},"a":{"a":0,"k":[13.842,13.842,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-7.507],[7.507,0],[0,7.507],[-7.506,0]],"o":[[0,7.507],[-7.506,0],[0,-7.507],[7.507,0]],"v":[[13.592,0],[0,13.592],[-13.592,0],[0,-13.592]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.203373763141,0.203600565592,0.203484329523,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[13.842,13.842],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600.000024438501,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"wire Outlines","parent":4,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":3,"s":[-28]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":6,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[-34]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":13,"s":[5]},{"t":17.0000006924242,"s":[0]}],"ix":10},"p":{"a":0,"k":[85.395,20.574,0],"ix":2,"l":2},"a":{"a":0,"k":[17.5,17.5,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-1.103,-3.49]],"o":[[0,0],[0,0]],"v":[[-2.663,-4.868],[2.663,4.868]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,0.999998743394,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":7,"ix":5},"lc":2,"lj":1,"ml":10,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[20.163,22.368],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600.000024438501,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"band Outlines","parent":12,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":3,"s":[-4]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":5,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":13,"s":[-4]},{"t":17.0000006924242,"s":[0]}],"ix":10},"p":{"a":0,"k":[44.581,150.745,0],"ix":2,"l":2},"a":{"a":0,"k":[52.884,15.431,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[2.98,0.163],[0,0],[-0.163,2.98],[0,0],[-2.98,-0.163],[0,0],[0.163,-2.98],[0,0]],"o":[[Line truncated
@@ -0,0 +1 @@
{"v":"5.5.5","fr":29.9700012207031,"ip":0,"op":38.0000015477717,"w":1024,"h":768,"nm":"Comp 1","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 10","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":27,"s":[100]},{"t":37.0000015070409,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"t":23,"s":[323,357,0],"to":[-15.333,-11,0],"ti":[15.333,11,0]},{"t":35.0000014255792,"s":[231,291,0]}],"ix":2},"a":{"a":0,"k":[-233,-159,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[38,38],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.094117654539,0.592156862745,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-233,-159],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":23.0000009368092,"op":38.0000015477717,"st":10.0000004073083,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 9","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":26,"s":[100]},{"t":36.0000014663101,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"t":22,"s":[685,325,0],"to":[17,-13.333,0],"ti":[-17,13.333,0]},{"t":34.0000013848484,"s":[787,245,0]}],"ix":2},"a":{"a":0,"k":[-233,-159,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[38,38],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.094117654539,0.592156862745,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-233,-159],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":22.0000008960784,"op":37.0000015070409,"st":9.00000036657752,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 8","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":19,"s":[100]},{"t":29.0000011811942,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"t":15,"s":[489,213,0],"to":[-0.333,-23.667,0],"ti":[0.333,23.667,0]},{"t":27.0000010997325,"s":[487,71,0]}],"ix":2},"a":{"a":0,"k":[-233,-159,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[38,38],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.094117654539,0.592156862745,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-233,-159],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":15.0000006109625,"op":30.0000012219251,"st":2.00000008146167,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"Shape Layer 7","td":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[512,384,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[74,74,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[1024,768],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":0,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0,1,0.583529423732,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":25.0000010182709,"op":900.000036657751,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"Shape Layer 6","tt":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":1},"o":{"x":0.167,"y":0},"t":25,"s":[507.984,852.584,0],"to":[0,-33.333,0],"ti":[0,33.333,0]},{"t":30.0000012219251,"s":[507Line truncated
@@ -5,6 +5,7 @@
xmlns:currentUser="clr-namespace:Artemis.UI.Screens.Workshop.CurrentUser"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.CurrentUser.CurrentUserView"
x:DataType="currentUser:CurrentUserViewModel">
@@ -27,13 +28,16 @@
</Ellipse>
<!-- Signed in -->
<Ellipse Height="{CompiledBinding Bounds.Height, ElementName=Container}" Width="{CompiledBinding Bounds.Height, ElementName=Container}" IsVisible="{CompiledBinding !IsAnonymous}" Name="UserMenu">
<Ellipse Height="{CompiledBinding Bounds.Height, ElementName=Container}"
Width="{CompiledBinding Bounds.Height, ElementName=Container}"
IsVisible="{CompiledBinding !IsAnonymous}"
Name="UserMenu">
<Ellipse.ContextFlyout>
<Flyout>
<Grid ColumnDefinitions="Auto,*" RowDefinitions="*,*,*" MinWidth="300">
<Ellipse Grid.Column="0" Grid.RowSpan="3" Height="50" Width="50" Margin="0 0 8 0" VerticalAlignment="Top">
<Ellipse.Fill>
<ImageBrush Source="{CompiledBinding Avatar}" />
<ImageBrush asyncImageLoader:ImageBrushLoader.Source="{CompiledBinding AvatarUrl}" />
</Ellipse.Fill>
</Ellipse>
<TextBlock Grid.Column="1" Grid.Row="0" Text="{CompiledBinding Name}" Margin="0 4 0 0"></TextBlock>
@@ -51,7 +55,7 @@
</Flyout>
</Ellipse.ContextFlyout>
<Ellipse.Fill>
<ImageBrush Source="{CompiledBinding Avatar}" />
<ImageBrush asyncImageLoader:ImageBrushLoader.Source="{CompiledBinding AvatarUrl}" />
</Ellipse.Fill>
</Ellipse>
</Panel>
@@ -21,7 +21,6 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
{
private readonly IAuthenticationService _authenticationService;
private readonly ObservableAsPropertyHelper<bool> _isAnonymous;
private readonly HttpClient _httpClient;
private readonly ILogger _logger;
private readonly IWindowService _windowService;
[Notify] private bool _allowLogout = true;
@@ -30,13 +29,13 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
[Notify(Setter.Private)] private bool _loading = true;
[Notify(Setter.Private)] private string? _name;
[Notify(Setter.Private)] private string? _userId;
[Notify(Setter.Private)] private string? _avatarUrl;
public CurrentUserViewModel(ILogger logger, IAuthenticationService authenticationService, IWindowService windowService)
{
_logger = logger;
_authenticationService = authenticationService;
_windowService = windowService;
_httpClient = new HttpClient();
Login = ReactiveCommand.CreateFromTask(ExecuteLogin);
_isAnonymous = this.WhenAnyValue(vm => vm.Loading, vm => vm.Name, (l, n) => l || n == null).ToProperty(this, vm => vm.IsAnonymous);
@@ -44,7 +43,7 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
this.WhenActivated(d =>
{
Task.Run(AutoLogin);
_authenticationService.IsLoggedIn.Subscribe(_ => Task.Run(LoadCurrentUser)).DisposeWith(d);
_authenticationService.IsLoggedIn.Subscribe(_ => LoadCurrentUser()).DisposeWith(d);
});
}
@@ -66,7 +65,7 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
.ShowAsync();
if (result == ContentDialogResult.Primary)
await LoadCurrentUser();
LoadCurrentUser();
}
private async Task AutoLogin()
@@ -74,7 +73,7 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
try
{
await _authenticationService.AutoLogin();
await LoadCurrentUser();
LoadCurrentUser();
}
catch (Exception e)
{
@@ -86,33 +85,11 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
}
}
private async Task LoadCurrentUser()
private void LoadCurrentUser()
{
UserId = _authenticationService.Claims.FirstOrDefault(c => c.Type == "sub")?.Value;
Name = _authenticationService.Claims.FirstOrDefault(c => c.Type == "name")?.Value;
Email = _authenticationService.Claims.FirstOrDefault(c => c.Type == "email")?.Value;
if (UserId != null)
{
await LoadAvatar(UserId);
}
else
{
Avatar?.Dispose();
Avatar = null;
}
}
private async Task LoadAvatar(string userId)
{
try
{
Avatar?.Dispose();
Avatar = new Bitmap(await _httpClient.GetStreamAsync($"{WorkshopConstants.AUTHORITY_URL}/user/avatar/{userId}"));
}
catch (Exception)
{
// ignored
}
AvatarUrl = $"{WorkshopConstants.AUTHORITY_URL}/user/avatar/{UserId}";
}
}
@@ -17,21 +17,21 @@
</StackPanel.Styles>
<StackPanel IsVisible="{CompiledBinding !Finished}">
<Lottie Path="/Assets/Animations/busy.json" Width="250" Height="250" Margin="0 100" ></Lottie>
<Lottie Path="/Assets/Animations/upload.json" Width="300" Height="300" Margin="0 75" ></Lottie>
<TextBlock Theme="{StaticResource TitleTextBlockStyle}">Uploading your submission...</TextBlock>
</StackPanel>
<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>
<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 Text="{CompiledBinding FailureMessage}"></TextBlock>
<TextBlock Margin="0 10" Classes="subtitle">If this keeps occuring, hit us up on Discord</TextBlock>
</StackPanel>
@@ -5,6 +5,7 @@ using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.UI.Shared.Routing;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Utilities;
@@ -31,6 +32,7 @@ public partial class UploadStepViewModel : SubmissionViewModel
[Notify] private bool _failed;
[Notify] private bool _finished;
[Notify] private bool _succeeded;
[Notify] private string? _failureMessage;
/// <inheritdoc />
public UploadStepViewModel(ILogger logger,
@@ -56,37 +58,33 @@ public partial class UploadStepViewModel : SubmissionViewModel
private async Task ExecuteUpload(CancellationToken cancellationToken)
{
// Use the existing entry or create a new one
_entryId = State.EntryId ?? await CreateEntry(cancellationToken);
// If a new entry had to be created but that failed, stop here, CreateEntry will send the user back
if (_entryId == null)
return;
try
{
// Use the existing entry or create a new one
_entryId = State.EntryId ?? await CreateEntry(cancellationToken);
if (_entryId == null)
{
Failed = true;
return;
}
// Create a release for the new entry
IEntryUploadHandler uploadHandler = _entryUploadHandlerFactory.CreateHandler(State.EntryType);
EntryUploadResult uploadResult = await uploadHandler.CreateReleaseAsync(_entryId.Value, State.EntrySource!, cancellationToken);
if (!uploadResult.IsSuccess)
{
string? message = uploadResult.Message;
if (message != null)
message += "\r\n\r\n";
else
message = "";
message += "Your submission has still been saved, you may try to upload a new release";
await _windowService.ShowConfirmContentDialog("Failed to upload workshop entry", message, "Close", null);
}
throw new ArtemisWorkshopException(uploadResult.Message);
Succeeded = true;
}
catch (Exception e)
{
_logger.Error(e, "Failed to upload submission for entry {EntryId}", _entryId);
// Something went wrong when creating a release :c
// We'll keep the workshop entry so that the user can make changes and try again
FailureMessage = e.Message;
Failed = true;
// If something went wrong halfway through, delete the entry
if (_entryId != null)
await _workshopClient.RemoveEntry.ExecuteAsync(_entryId.Value, CancellationToken.None);
}
finally
{
@@ -94,10 +92,12 @@ public partial class UploadStepViewModel : SubmissionViewModel
}
}
private async Task<long?> CreateEntry(CancellationToken cancellationToken)
private async Task<long> CreateEntry(CancellationToken cancellationToken)
{
await Task.Delay(2000);
// Let the UI settle before making the thread busy
await Task.Delay(500, cancellationToken);
// Create entry
IOperationResult<IAddEntryResult> result = await _workshopClient.AddEntry.ExecuteAsync(new CreateEntryInput
{
EntryType = State.EntryType,
@@ -108,18 +108,16 @@ public partial class UploadStepViewModel : SubmissionViewModel
Tags = State.Tags
}, cancellationToken);
long? entryId = result.Data?.AddEntry?.Id;
if (result.IsErrorResult() || entryId == null)
{
await _windowService.ShowConfirmContentDialog("Failed to create workshop entry", string.Join("\r\n", result.Errors.Select(e => e.Message)), "Close", null);
State.ChangeScreen<SubmitStepViewModel>();
return null;
}
result.EnsureNoErrors();
if (result.Data?.AddEntry == null)
throw new ArtemisWorkshopException("AddEntry returned result");
long entryId = result.Data.AddEntry.Id;
// Upload images
cancellationToken.ThrowIfCancellationRequested();
foreach (ImageUploadRequest image in State.Images.ToList())
{
await TryImageUpload(async () => await _workshopService.UploadEntryImage(entryId.Value, image, cancellationToken));
await TryImageUpload(async () => await _workshopService.UploadEntryImage(entryId, image, cancellationToken));
cancellationToken.ThrowIfCancellationRequested();
}
@@ -127,8 +125,7 @@ public partial class UploadStepViewModel : SubmissionViewModel
return entryId;
// Upload icon
await TryImageUpload(async () => await _workshopService.SetEntryIcon(entryId.Value, State.Icon, cancellationToken));
await TryImageUpload(async () => await _workshopService.SetEntryIcon(entryId, State.Icon, cancellationToken));
return entryId;
}
@@ -151,7 +148,7 @@ public partial class UploadStepViewModel : SubmissionViewModel
{
State.Close();
if (_entryId != null)
if (Succeeded && _entryId != null)
await _router.Navigate($"workshop/library/submissions/{_entryId.Value}");
}
}
@@ -45,6 +45,9 @@
<GraphQL Update="Mutations\UpdateEntryImage.graphql">
<Generator>MSBuild:GenerateGraphQLCode</Generator>
</GraphQL>
<GraphQL Update="Mutations\CreateEntry.graphql">
<Generator>MSBuild:GenerateGraphQLCode</Generator>
</GraphQL>
</ItemGroup>
<ItemGroup>