From ffe2e0d35a6889b31b1865592fcaa49be5eaa3a9 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Sat, 20 Jul 2024 12:23:26 +0100 Subject: [PATCH] Thanks gdk --- src/Ryujinx/UI/Models/TitleUpdateModel.cs | 16 ++++++------ .../UI/ViewModels/TitleUpdateViewModel.cs | 26 ++++--------------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/Ryujinx/UI/Models/TitleUpdateModel.cs b/src/Ryujinx/UI/Models/TitleUpdateModel.cs index cde37bf915..9f61f09990 100644 --- a/src/Ryujinx/UI/Models/TitleUpdateModel.cs +++ b/src/Ryujinx/UI/Models/TitleUpdateModel.cs @@ -5,17 +5,17 @@ namespace Ryujinx.Ava.UI.Models { public class TitleUpdateModel { - public ApplicationControlProperty Control { get; } + public uint Version { get; } public string Path { get; } + public string Label { get; } - public string Label => LocaleManager.Instance.UpdateAndGetDynamicValue( - System.IO.Path.GetExtension(Path)?.ToLower() == ".xci" ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel, - Control.DisplayVersionString.ToString() - ); - - public TitleUpdateModel(ApplicationControlProperty control, string path) + public TitleUpdateModel(uint version, string displayVersion, string path) { - Control = control; + Version = version; + Label = LocaleManager.Instance.UpdateAndGetDynamicValue( + System.IO.Path.GetExtension(path)?.ToLower() == ".xci" ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel, + displayVersion + ); Path = path; } } diff --git a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs index 71e40f96f2..1e73b671cb 100644 --- a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs @@ -131,29 +131,11 @@ namespace Ryujinx.Ava.UI.ViewModels public void SortUpdates() { - var list = TitleUpdates.ToList(); - - list.Sort((first, second) => - { - var firstVersion = first.Control.DisplayVersionString.ToString(); - var secondVersion = second.Control.DisplayVersionString.ToString(); - - if (string.IsNullOrEmpty(firstVersion)) - { - return -1; - } - - if (string.IsNullOrEmpty(secondVersion)) - { - return 1; - } - - return String.Compare(firstVersion, secondVersion, StringComparison.InvariantCulture) * -1; - }); + var sortedUpdates = TitleUpdates.OrderByDescending(update => update.Version); Views.Clear(); Views.Add(new BaseModel()); - Views.AddRange(list); + Views.AddRange(sortedUpdates); if (SelectedUpdate == null) { @@ -207,7 +189,9 @@ namespace Ryujinx.Ava.UI.ViewModels controlNca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None).OpenFile(ref nacpFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure(); nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData), ReadOption.None).ThrowIfFailure(); - TitleUpdates.Add(new TitleUpdateModel(controlData, path)); + var displayVersion = controlData.DisplayVersionString.ToString(); + + TitleUpdates.Add(new TitleUpdateModel(content.Version.Version, displayVersion, path)); } else {