1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

Merge branch 'development'

This commit is contained in:
Robert 2023-09-20 22:55:52 +02:00
commit c466d03988
8 changed files with 24 additions and 23 deletions

View File

@ -31,7 +31,6 @@ public class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsViewModel>
private readonly IRouter _router;
private readonly SourceList<IGetReleases_PublishedReleases_Nodes> _releases;
private bool _loading;
private IGetReleases_PublishedReleases_PageInfo? _lastPageInfo;
private ReleaseViewModel? _selectedReleaseViewModel;
public ReleasesTabViewModel(ILogger logger, IUpdateService updateService, IUpdatingClient updatingClient, IReleaseVmFactory releaseVmFactory, INotificationService notificationService,
@ -75,21 +74,21 @@ public class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsViewModel>
private set => RaiseAndSetIfChanged(ref _loading, value);
}
public async Task GetMoreReleases(CancellationToken cancellationToken)
public async Task GetReleases(CancellationToken cancellationToken)
{
if (_lastPageInfo != null && !_lastPageInfo.HasNextPage)
return;
try
{
Loading = true;
IOperationResult<IGetReleasesResult> result = await _updatingClient.GetReleases.ExecuteAsync(_updateService.Channel, Platform.Windows, 20, _lastPageInfo?.EndCursor, cancellationToken);
IOperationResult<IGetReleasesResult> result = await _updatingClient.GetReleases.ExecuteAsync(_updateService.Channel, Platform.Windows, cancellationToken);
if (result.Data?.PublishedReleases?.Nodes == null)
return;
_lastPageInfo = result.Data.PublishedReleases.PageInfo;
_releases.AddRange(result.Data.PublishedReleases.Nodes);
_releases.Edit(r =>
{
r.Clear();
r.AddRange(result.Data.PublishedReleases.Nodes);
});
}
catch (TaskCanceledException)
{
@ -114,7 +113,7 @@ public class ReleasesTabViewModel : RoutableHostScreen<ReleaseDetailsViewModel>
public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
{
if (!ReleaseViewModels.Any())
await GetMoreReleases(cancellationToken);
await GetReleases(cancellationToken);
// If there is an ID parameter further down the path, preselect it
if (args.RouteParameters.Length > 0 && args.RouteParameters[0] is Guid releaseId)

View File

@ -33,8 +33,7 @@ public class LoginStepViewModel : SubmissionViewModel
if (result != ContentDialogResult.Primary)
return;
Claim? emailVerified = _authenticationService.Claims.FirstOrDefault(c => c.Type == JwtClaimTypes.EmailVerified);
if (emailVerified?.Value == "true")
if (_authenticationService.GetIsEmailVerified())
State.ChangeScreen<EntryTypeStepViewModel>();
else
State.ChangeScreen<ValidateEmailStepViewModel>();

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading;
@ -138,7 +139,7 @@ public class UploadStepViewModel : SubmissionViewModel
long? entryId = result.Data?.AddEntry?.Id;
if (result.IsErrorResult() || entryId == null)
{
await _windowService.ShowConfirmContentDialog("Failed to create workshop entry", result.Errors.ToString() ?? "Not even an error message", "Close", 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;
}

View File

@ -54,9 +54,7 @@ public class ValidateEmailStepViewModel : SubmissionViewModel
{
// Use the refresh token to login again, updating claims
await _authenticationService.AutoLogin(true);
Claim? emailVerified = _authenticationService.Claims.FirstOrDefault(c => c.Type == JwtClaimTypes.EmailVerified);
if (emailVerified?.Value == "true")
if (_authenticationService.GetIsEmailVerified())
ExecuteContinue();
}
catch (Exception)

View File

@ -29,7 +29,7 @@ public class WelcomeStepViewModel : SubmissionViewModel
}
else
{
if (_authenticationService.Claims.Any(c => c.Type == JwtClaimTypes.EmailVerified && c.Value == "true"))
if (_authenticationService.GetIsEmailVerified())
State.ChangeScreen<EntryTypeStepViewModel>();
else
State.ChangeScreen<ValidateEmailStepViewModel>();

View File

@ -1,7 +1,7 @@
query GetReleases($branch: String!, $platform: Platform!, $take: Int!, $after: String) {
query GetReleases($branch: String!, $platform: Platform!) {
publishedReleases(
first: $take
after: $after
order: {createdAt: DESC}
first: 50
where: {
and: [
{ branch: { eq: $branch } }
@ -9,10 +9,6 @@ query GetReleases($branch: String!, $platform: Platform!, $take: Int!, $after: S
]
}
) {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
version

View File

@ -266,6 +266,13 @@ internal class AuthenticationService : CorePropertyChanged, IAuthenticationServi
_isLoggedInSubject.OnNext(false);
}
/// <inheritdoc />
public bool GetIsEmailVerified()
{
Claim? emailVerified = Claims.FirstOrDefault(c => c.Type == JwtClaimTypes.EmailVerified);
return emailVerified?.Value.ToLower() == "true";
}
private async Task<bool> InternalAutoLogin(bool force = false)
{
if (!force && _isLoggedInSubject.Value)

View File

@ -14,4 +14,5 @@ public interface IAuthenticationService : IProtectedArtemisService
Task<bool> AutoLogin(bool force = false);
Task Login(CancellationToken cancellationToken);
void Logout();
bool GetIsEmailVerified();
}