diff --git a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs index c74580dfd..9507170d3 100644 --- a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs @@ -13,6 +13,7 @@ using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Threading.Tasks; +using static Ryujinx.Ava.Utilities.StorageProviderExtensions; namespace Ryujinx.Ava.UI.ViewModels { @@ -128,7 +129,7 @@ namespace Ryujinx.Ava.UI.ViewModels public async void Add() { - IReadOnlyList result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + IReadOnlyList result = await CoreDumpable(() => _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.SelectDlcDialogTitle], AllowMultiple = true, @@ -141,7 +142,7 @@ namespace Ryujinx.Ava.UI.ViewModels MimeTypes = ["application/x-nx-nsp"], }, }, - }); + })); int totalDlcAdded = 0; foreach (IStorageFile file in result) diff --git a/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs index 45e67add0..14b0f1fa5 100644 --- a/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs @@ -17,6 +17,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; +using static Ryujinx.Ava.Utilities.StorageProviderExtensions; namespace Ryujinx.Ava.UI.ViewModels { @@ -288,11 +289,11 @@ namespace Ryujinx.Ava.UI.ViewModels public async void Add() { - IReadOnlyList result = await _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions + IReadOnlyList result = await CoreDumpable(() => _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.SelectModDialogTitle], AllowMultiple = true, - }); + })); foreach (IStorageFolder folder in result) { diff --git a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs index 8393bc93c..c73553f80 100644 --- a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; +using static Ryujinx.Ava.Utilities.StorageProviderExtensions; namespace Ryujinx.Ava.UI.ViewModels { @@ -148,7 +149,7 @@ namespace Ryujinx.Ava.UI.ViewModels public async Task Add() { - IReadOnlyList result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + IReadOnlyList result = await CoreDumpable(() => _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions { AllowMultiple = true, FileTypeFilter = new List @@ -160,7 +161,7 @@ namespace Ryujinx.Ava.UI.ViewModels MimeTypes = ["application/x-nx-nsp"], }, }, - }); + })); int totalUpdatesAdded = 0; foreach (IStorageFile file in result) diff --git a/src/Ryujinx/UI/Views/User/UserProfileImageSelectorView.axaml.cs b/src/Ryujinx/UI/Views/User/UserProfileImageSelectorView.axaml.cs index 3a5b7c6b7..9ee2aacf2 100644 --- a/src/Ryujinx/UI/Views/User/UserProfileImageSelectorView.axaml.cs +++ b/src/Ryujinx/UI/Views/User/UserProfileImageSelectorView.axaml.cs @@ -4,10 +4,12 @@ using Avalonia.Platform.Storage; using Avalonia.VisualTree; using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Navigation; +using Gommon; using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.UI.Controls; using Ryujinx.Ava.UI.Models; using Ryujinx.Ava.UI.ViewModels; +using Ryujinx.Ava.Utilities; using Ryujinx.HLE.FileSystem; using SkiaSharp; using System.Collections.Generic; @@ -62,7 +64,7 @@ namespace Ryujinx.Ava.UI.Views.User private async void Import_OnClick(object sender, RoutedEventArgs e) { - IReadOnlyList result = await ((Window)this.GetVisualRoot()!).StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + Optional result = await ((Window)this.GetVisualRoot()!).StorageProvider.OpenSingleFilePickerAsync(new FilePickerOpenOptions { AllowMultiple = false, FileTypeFilter = new List @@ -76,9 +78,9 @@ namespace Ryujinx.Ava.UI.Views.User }, }); - if (result.Count > 0) + if (result.HasValue) { - _profile.Image = ProcessProfileImage(File.ReadAllBytes(result[0].Path.LocalPath)); + _profile.Image = ProcessProfileImage(File.ReadAllBytes(result.Value.Path.LocalPath)); _parent.GoBack(); } } diff --git a/src/Ryujinx/Utilities/StorageProviderExtensions.cs b/src/Ryujinx/Utilities/StorageProviderExtensions.cs index 2735d4336..28eed5fa5 100644 --- a/src/Ryujinx/Utilities/StorageProviderExtensions.cs +++ b/src/Ryujinx/Utilities/StorageProviderExtensions.cs @@ -29,7 +29,7 @@ namespace Ryujinx.Ava.Utilities .Then(files => files.Count > 0 ? Optional.Of(files) : default); } - private static async Task CoreDumpable(Func> picker) + public static async Task CoreDumpable(Func> picker) { OsUtils.SetCoreDumpable(true); try