From 81f225181932a13a83b6ad92a3dca98918df0066 Mon Sep 17 00:00:00 2001 From: Johnny Date: Tue, 25 Apr 2023 12:08:49 +0200 Subject: [PATCH 1/4] periodically force-refresh the SDK list --- src/Constants.cs | 3 ++- src/MainPage.xaml.cs | 11 ++++++++++- src/Services/DotnetService.cs | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Constants.cs b/src/Constants.cs index cdb17ae..29d75cc 100644 --- a/src/Constants.cs +++ b/src/Constants.cs @@ -9,7 +9,8 @@ namespace Dots; public class Constants { public const string AppName = "Dots"; - public const string InstalledSdkSKey = "Installed-Sdks-Key"; + public const string InstalledSdkSKey = "installed-sdks-key"; + public const string LastCheckedKey = "last-checked"; #if MACCATALYST public const string UninstallerPath = "Package Cache"; public const string InstallerScript = "https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh"; diff --git a/src/MainPage.xaml.cs b/src/MainPage.xaml.cs index 53c8538..c72dfcb 100644 --- a/src/MainPage.xaml.cs +++ b/src/MainPage.xaml.cs @@ -29,7 +29,16 @@ public MainPage(MainViewModel vm) protected async override void OnAppearing() { base.OnAppearing(); - await _vm.CheckSdks(); + var lastChecked = Preferences.Get(Constants.LastCheckedKey, DateTime.MinValue); + + bool force = false; + if (DateTime.Now.Subtract(lastChecked).TotalDays > 15) + { + force = true; + Preferences.Set(Constants.LastCheckedKey, DateTime.Now); + } + await _vm.CheckSdks(force); + } private async void CollapseDetails_Tapped(object sender, Microsoft.Maui.Controls.TappedEventArgs e) diff --git a/src/Services/DotnetService.cs b/src/Services/DotnetService.cs index 085e553..453b0e2 100644 --- a/src/Services/DotnetService.cs +++ b/src/Services/DotnetService.cs @@ -27,12 +27,12 @@ public class DotnetService public async Task> GetSdks(bool force = false) { var result = new List(); - var index = await GetReleaseIndex(); + var index = await GetReleaseIndex(force); var releaseInfos = new List(); var installed = GetInstalledSdks(force); foreach(var item in index) { - var infos = await GetReleaseInfos(item.ChannelVersion); + var infos = await GetReleaseInfos(item.ChannelVersion, force); releaseInfos.AddRange(infos); } int i = 0; From 7bdee748bd7da628952c4e2fdf17d54cc0a7c261 Mon Sep 17 00:00:00 2001 From: Johnny Date: Tue, 25 Apr 2023 12:40:45 +0200 Subject: [PATCH 2/4] do not throw exception from enum converter --- src/Data/ReleaseIndex.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Data/ReleaseIndex.cs b/src/Data/ReleaseIndex.cs index ed1440f..48ce45c 100644 --- a/src/Data/ReleaseIndex.cs +++ b/src/Data/ReleaseIndex.cs @@ -46,11 +46,11 @@ public class ReleaseIndex public Uri ReleasesJson { get; set; } } -public enum Product { Net, NetCore }; +public enum Product { Net, NetCore, Undefined }; -public enum ReleaseType { Lts, Sts }; +public enum ReleaseType { Lts, Sts, Undefined }; -public enum SupportPhase { Active, Eol, Preview }; +public enum SupportPhase { Active, Eol, Preview, Undefined }; public class ProductEnumConverter : JsonConverter @@ -61,7 +61,7 @@ public override Product Read(ref Utf8JsonReader reader, Type typeToConvert, Json { ".NET" => Product.Net, ".NET Core" => Product.NetCore, - _ => throw new JsonException() + _ => Product.Undefined }; } @@ -71,7 +71,7 @@ public override void Write(Utf8JsonWriter writer, Product value, JsonSerializerO { Product.Net => ".NET", Product.NetCore => ".NET Core", - _ => throw new JsonException() + _ => "" }); } } @@ -84,7 +84,7 @@ public override ReleaseType Read(ref Utf8JsonReader reader, Type typeToConvert, { "lts" => ReleaseType.Lts, "sts" => ReleaseType.Sts, - _ => throw new JsonException() + _ => ReleaseType.Undefined }; } @@ -94,7 +94,7 @@ public override void Write(Utf8JsonWriter writer, ReleaseType value, JsonSeriali { ReleaseType.Lts => "lts", ReleaseType.Sts => "sts", - _ => throw new JsonException() + _ => "" }); } } @@ -108,7 +108,7 @@ public override SupportPhase Read(ref Utf8JsonReader reader, Type typeToConvert, "preview" => SupportPhase.Preview, "active" => SupportPhase.Active, "eol" => SupportPhase.Eol, - _ => throw new JsonException() + _ => SupportPhase.Undefined }; } @@ -119,7 +119,7 @@ public override void Write(Utf8JsonWriter writer, SupportPhase value, JsonSerial SupportPhase.Preview => "preview", SupportPhase.Active => "active", SupportPhase.Eol => "eol", - _ => throw new JsonException() + _ => "" }); } } From cebe885ed3a0dd2fd6bd3dfd9b0d218473eb8642 Mon Sep 17 00:00:00 2001 From: Johnny Date: Tue, 25 Apr 2023 14:31:48 +0200 Subject: [PATCH 3/4] =?UTF-8?q?various=20UI=20improvements=20=F0=9F=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - loading overlay - animation background / border de-glitched --- src/MainPage.xaml | 18 ++++++++++++++++-- src/MainPage.xaml.cs | 14 +++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/MainPage.xaml b/src/MainPage.xaml index deb3758..31c0892 100644 --- a/src/MainPage.xaml +++ b/src/MainPage.xaml @@ -629,15 +629,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/MainPage.xaml.cs b/src/MainPage.xaml.cs index c72dfcb..4e69823 100644 --- a/src/MainPage.xaml.cs +++ b/src/MainPage.xaml.cs @@ -10,6 +10,7 @@ using System; using System.Diagnostics; using static System.Runtime.InteropServices.JavaScript.JSType; +using Microsoft.Maui.Platform; namespace Dots; @@ -22,10 +23,21 @@ public MainPage(MainViewModel vm) InitializeComponent(); AnimationView.Source = new HtmlWebViewSource() { - Html = $$"""