mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Workshop - Update workshop IDs to be long
This commit is contained in:
1 parent
a798980eec
commit
0fdb40bd35
33 files changed
+102
-103
No files matched your search
@@ -46,16 +46,16 @@ public class CategoriesViewModel : ActivatableViewModelBase
|
||||
|
||||
private IReadOnlyList<EntryFilterInput>? CreateFilter()
|
||||
{
|
||||
List<int?> categories = Categories.Where(c => c.IsSelected).Select(c => (int?) c.Id).ToList();
|
||||
List<long?> categories = Categories.Where(c => c.IsSelected).Select(c => (long?) c.Id).ToList();
|
||||
if (!categories.Any())
|
||||
return null;
|
||||
|
||||
List<EntryFilterInput> categoryFilters = new();
|
||||
foreach (int? category in categories)
|
||||
foreach (long? category in categories)
|
||||
{
|
||||
categoryFilters.Add(new EntryFilterInput
|
||||
{
|
||||
Categories = new ListFilterInputTypeOfCategoryFilterInput {Some = new CategoryFilterInput {Id = new IntOperationFilterInput {Eq = category}}}
|
||||
Categories = new ListFilterInputTypeOfCategoryFilterInput {Some = new CategoryFilterInput {Id = new LongOperationFilterInput {Eq = category}}}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class CategoryViewModel : ViewModelBase
|
||||
Icon = icon as MaterialIconKind? ?? MaterialIconKind.QuestionMarkCircle;
|
||||
}
|
||||
|
||||
public int Id { get; }
|
||||
public long Id { get; }
|
||||
public string Name { get; }
|
||||
public MaterialIconKind Icon { get; }
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class EntrySpecificationsViewModel : ValidatableViewModelBase
|
||||
.AutoRefresh(c => c.IsSelected)
|
||||
.Filter(c => c.IsSelected)
|
||||
.Transform(c => c.Id)
|
||||
.Bind(out ReadOnlyObservableCollection<int> selectedCategories)
|
||||
.Bind(out ReadOnlyObservableCollection<long> selectedCategories)
|
||||
.Subscribe();
|
||||
SelectedCategories = selectedCategories;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class EntrySpecificationsViewModel : ValidatableViewModelBase
|
||||
|
||||
public ObservableCollection<CategoryViewModel> Categories { get; } = new();
|
||||
public ObservableCollection<string> Tags { get; } = new();
|
||||
public ReadOnlyObservableCollection<int> SelectedCategories { get; }
|
||||
public ReadOnlyObservableCollection<long> SelectedCategories { get; }
|
||||
|
||||
public bool CategoriesValid => _categoriesValid.Value ;
|
||||
public bool IconValid => _iconValid.Value;
|
||||
@@ -127,7 +127,7 @@ public class EntrySpecificationsViewModel : ValidatableViewModelBase
|
||||
private set => RaiseAndSetIfChanged(ref _iconChanged, value);
|
||||
}
|
||||
|
||||
public List<int> PreselectedCategories { get; set; } = new();
|
||||
public List<long> PreselectedCategories { get; set; } = new();
|
||||
|
||||
private void MarkdownDocumentOnTextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ public class LayoutDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
||||
await GetEntry(parameters.EntryId, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task GetEntry(Guid entryId, CancellationToken cancellationToken)
|
||||
private async Task GetEntry(long entryId, CancellationToken cancellationToken)
|
||||
{
|
||||
IOperationResult<IGetEntryByIdResult> result = await _client.GetEntryById.ExecuteAsync(entryId, cancellationToken);
|
||||
if (result.IsErrorResult())
|
||||
|
||||
@@ -136,7 +136,7 @@ public class SubmissionDetailViewModel : RoutableScreen<WorkshopDetailParameters
|
||||
if (EntrySpecificationsViewModel == null || Entry == null)
|
||||
return;
|
||||
|
||||
List<int> categories = EntrySpecificationsViewModel.Categories.Where(c => c.IsSelected).Select(c => c.Id).OrderBy(c => c).ToList();
|
||||
List<long> categories = EntrySpecificationsViewModel.Categories.Where(c => c.IsSelected).Select(c => c.Id).OrderBy(c => c).ToList();
|
||||
List<string> tags = EntrySpecificationsViewModel.Tags.OrderBy(t => t).ToList();
|
||||
|
||||
HasChanges = EntrySpecificationsViewModel.Name != Entry.Name ||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Artemis.UI.Screens.Workshop.Library.Tabs;
|
||||
public class SubmissionsTabViewModel : RoutableScreen
|
||||
{
|
||||
private readonly IWorkshopClient _client;
|
||||
private readonly SourceCache<IGetSubmittedEntries_SubmittedEntries, Guid> _entries;
|
||||
private readonly SourceCache<IGetSubmittedEntries_SubmittedEntries, long> _entries;
|
||||
private readonly IWindowService _windowService;
|
||||
private bool _isLoading = true;
|
||||
private bool _workshopReachable;
|
||||
@@ -32,7 +32,7 @@ public class SubmissionsTabViewModel : RoutableScreen
|
||||
{
|
||||
_client = client;
|
||||
_windowService = windowService;
|
||||
_entries = new SourceCache<IGetSubmittedEntries_SubmittedEntries, Guid>(e => e.Id);
|
||||
_entries = new SourceCache<IGetSubmittedEntries_SubmittedEntries, long>(e => e.Id);
|
||||
_entries.Connect()
|
||||
.Transform(getSubmissionsTabItemViewModel)
|
||||
.Bind(out ReadOnlyObservableCollection<SubmissionsTabItemViewModel> entries)
|
||||
@@ -54,7 +54,6 @@ public class SubmissionsTabViewModel : RoutableScreen
|
||||
|
||||
public ReactiveCommand<Unit, Unit> Login { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddSubmission { get; }
|
||||
public ReactiveCommand<IGetSubmittedEntries_SubmittedEntries, Unit> NavigateToEntry { get; }
|
||||
|
||||
public IObservable<bool> IsLoggedIn { get; }
|
||||
public ReadOnlyObservableCollection<SubmissionsTabItemViewModel> Entries { get; }
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Parameters;
|
||||
|
||||
public class WorkshopDetailParameters
|
||||
{
|
||||
public Guid EntryId { get; set; }
|
||||
public long EntryId { get; set; }
|
||||
}
|
||||
@@ -3,7 +3,6 @@ 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.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@@ -52,7 +51,7 @@ public class ProfileDetailsViewModel : RoutableScreen<WorkshopDetailParameters>
|
||||
await GetEntry(parameters.EntryId, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task GetEntry(Guid entryId, CancellationToken cancellationToken)
|
||||
private async Task GetEntry(long entryId, CancellationToken cancellationToken)
|
||||
{
|
||||
IOperationResult<IGetEntryByIdResult> result = await _client.GetEntryById.ExecuteAsync(entryId, cancellationToken);
|
||||
if (result.IsErrorResult())
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||
using Artemis.UI.Screens.Workshop.CurrentUser;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using ReactiveUI;
|
||||
@@ -18,17 +17,17 @@ namespace Artemis.UI.Screens.Workshop.Search;
|
||||
public class SearchViewModel : ViewModelBase
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRouter _router;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
private readonly IDebugService _debugService;
|
||||
private readonly IWorkshopClient _workshopClient;
|
||||
private bool _isLoading;
|
||||
private SearchResultViewModel? _selectedEntry;
|
||||
|
||||
public SearchViewModel(ILogger logger, IWorkshopClient workshopClient, IRouter router, CurrentUserViewModel currentUserViewModel, IDebugService debugService)
|
||||
public SearchViewModel(ILogger logger, IWorkshopClient workshopClient, IWorkshopService workshopService, CurrentUserViewModel currentUserViewModel, IDebugService debugService)
|
||||
{
|
||||
_logger = logger;
|
||||
_workshopClient = workshopClient;
|
||||
_router = router;
|
||||
_workshopService = workshopService;
|
||||
_debugService = debugService;
|
||||
CurrentUserViewModel = currentUserViewModel;
|
||||
SearchAsync = ExecuteSearchAsync;
|
||||
@@ -59,14 +58,7 @@ public class SearchViewModel : ViewModelBase
|
||||
|
||||
private void NavigateToEntry(SearchResultViewModel searchResult)
|
||||
{
|
||||
string? url = null;
|
||||
if (searchResult.Entry.EntryType == WebClient.Workshop.EntryType.Profile)
|
||||
url = $"workshop/entries/profiles/{searchResult.Entry.Id}";
|
||||
if (searchResult.Entry.EntryType == WebClient.Workshop.EntryType.Layout)
|
||||
url = $"workshop/entries/layouts/{searchResult.Entry.Id}";
|
||||
|
||||
if (url != null)
|
||||
Task.Run(() => _router.Navigate(url));
|
||||
_workshopService.NavigateToEntry(searchResult.Entry.Id, searchResult.Entry.EntryType);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<object>> ExecuteSearchAsync(string? input, CancellationToken cancellationToken)
|
||||
|
||||
@@ -11,12 +11,14 @@ using Artemis.WebClient.Workshop.Exceptions;
|
||||
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
using ReactiveUI;
|
||||
using Serilog;
|
||||
using StrawberryShake;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
||||
|
||||
public class UploadStepViewModel : SubmissionViewModel
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly EntryUploadHandlerFactory _entryUploadHandlerFactory;
|
||||
private readonly Progress<StreamProgress> _progress = new();
|
||||
private readonly ObservableAsPropertyHelper<bool> _progressIndeterminate;
|
||||
@@ -26,14 +28,20 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
private readonly IWorkshopClient _workshopClient;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
|
||||
private Guid? _entryId;
|
||||
private long? _entryId;
|
||||
private bool _failed;
|
||||
private bool _finished;
|
||||
private bool _succeeded;
|
||||
|
||||
/// <inheritdoc />
|
||||
public UploadStepViewModel(IWorkshopClient workshopClient, IWorkshopService workshopService, EntryUploadHandlerFactory entryUploadHandlerFactory, IWindowService windowService, IRouter router)
|
||||
public UploadStepViewModel(ILogger logger,
|
||||
IWorkshopClient workshopClient,
|
||||
IWorkshopService workshopService,
|
||||
EntryUploadHandlerFactory entryUploadHandlerFactory,
|
||||
IWindowService windowService,
|
||||
IRouter router)
|
||||
{
|
||||
_logger = logger;
|
||||
_workshopClient = workshopClient;
|
||||
_workshopService = workshopService;
|
||||
_entryUploadHandlerFactory = entryUploadHandlerFactory;
|
||||
@@ -101,8 +109,10 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
|
||||
Succeeded = true;
|
||||
}
|
||||
catch (Exception)
|
||||
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
|
||||
Failed = true;
|
||||
@@ -113,7 +123,7 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Guid?> CreateEntry(CancellationToken cancellationToken)
|
||||
private async Task<long?> CreateEntry(CancellationToken cancellationToken)
|
||||
{
|
||||
IOperationResult<IAddEntryResult> result = await _workshopClient.AddEntry.ExecuteAsync(new CreateEntryInput
|
||||
{
|
||||
@@ -125,7 +135,7 @@ public class UploadStepViewModel : SubmissionViewModel
|
||||
Tags = State.Tags
|
||||
}, cancellationToken);
|
||||
|
||||
Guid? entryId = result.Data?.AddEntry?.Id;
|
||||
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);
|
||||
|
||||
@@ -22,14 +22,14 @@ public class SubmissionWizardState
|
||||
}
|
||||
|
||||
public EntryType EntryType { get; set; }
|
||||
public Guid? EntryId { get; set; }
|
||||
public long? EntryId { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public Stream? Icon { get; set; }
|
||||
public string Summary { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public List<int> Categories { get; set; } = new();
|
||||
public List<long> Categories { get; set; } = new();
|
||||
public List<string> Tags { get; set; } = new();
|
||||
public List<Stream> Images { get; set; } = new();
|
||||
|
||||
|
||||
Reference in new issue
Block a user