From 327b2d72f89ed615b935eaf4459f07ba0dda630c Mon Sep 17 00:00:00 2001 From: Soapwood Date: Wed, 24 Jul 2024 23:27:30 +0100 Subject: [PATCH] Properly order releases in AutoUpdater when pulled from github. --- VXAutoUpdater/Core/VXMusicAutoUpdater.cs | 16 ++++++++++++++-- VXMusicDesktop/VXMusicDesktop.csproj | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/VXAutoUpdater/Core/VXMusicAutoUpdater.cs b/VXAutoUpdater/Core/VXMusicAutoUpdater.cs index 4baa7d8..f901a3e 100644 --- a/VXAutoUpdater/Core/VXMusicAutoUpdater.cs +++ b/VXAutoUpdater/Core/VXMusicAutoUpdater.cs @@ -108,9 +108,15 @@ public async Task> GetLatestVersionsForBranch(string branch) releasesToDisplay = allReleases.Where(release => !release.Prerelease && !release.Draft); else if(string.Equals("Nightly", branch)) releasesToDisplay = allReleases.Where(release => release.Prerelease && !release.Draft ); + + var orderedReleases = releasesToDisplay + .Select(release => new { Release = release, Version = ParseVersion(release.TagName) }) + .Where(x => x.Version != null) + .OrderByDescending(x => x.Version) + .Select(x => x.Release) + .ToList(); - - return releasesToDisplay.ToList(); + return orderedReleases; } catch (Exception ex) { @@ -120,6 +126,12 @@ public async Task> GetLatestVersionsForBranch(string branch) // No new update available or error occurred return null; } + + private static Version ParseVersion(string versionString) + { + Version version; + return Version.TryParse(versionString, out version) ? version : null; + } public async Task DownloadUpdate(Release release) { diff --git a/VXMusicDesktop/VXMusicDesktop.csproj b/VXMusicDesktop/VXMusicDesktop.csproj index 2c43761..b72f9a0 100644 --- a/VXMusicDesktop/VXMusicDesktop.csproj +++ b/VXMusicDesktop/VXMusicDesktop.csproj @@ -9,7 +9,7 @@ VXLogo.png Images\VXLogoIcon.ico Always - 0.6.4.11 + 0.6.4.12 en VXMusicDesktop VirtualXtensions