Workshop - Added library view models

This commit is contained in:
Robert committed 2023-08-31 22:04:57 +02:00
1 parent c75e839756
commit e545d2f3da
18 files changed
+272 -41

No files matched your search

@@ -23,14 +23,16 @@ public class ProfileDetailsViewModel : RoutableScreen<ActivatableViewModelBase,
private readonly IWorkshopClient _client;
private readonly ProfileEntryDownloadHandler _downloadHandler;
private readonly INotificationService _notificationService;
private readonly IWindowService _windowService;
private readonly ObservableAsPropertyHelper<DateTimeOffset?> _updatedAt;
private IGetEntryById_Entry? _entry;
public ProfileDetailsViewModel(IWorkshopClient client, ProfileEntryDownloadHandler downloadHandler, INotificationService notificationService)
public ProfileDetailsViewModel(IWorkshopClient client, ProfileEntryDownloadHandler downloadHandler, INotificationService notificationService, IWindowService windowService)
{
_client = client;
_downloadHandler = downloadHandler;
_notificationService = notificationService;
_windowService = windowService;
_updatedAt = this.WhenAnyValue(vm => vm.Entry).Select(e => e?.LatestRelease?.CreatedAt ?? e?.CreatedAt).ToProperty(this, vm => vm.UpdatedAt);
DownloadLatestRelease = ReactiveCommand.CreateFromTask(ExecuteDownloadLatestRelease);
@@ -65,6 +67,10 @@ public class ProfileDetailsViewModel : RoutableScreen<ActivatableViewModelBase,
if (Entry?.LatestRelease == null)
return;
bool confirm = await _windowService.ShowConfirmContentDialog("Install profile?", "The profile will be downloaded and added to your sidebar automatically.");
if (!confirm)
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();