From a60d11712435d4d9bc5b1ef9f78f15c54d7bd72e Mon Sep 17 00:00:00 2001 From: Yaser Moradi Date: Wed, 23 Oct 2024 17:07:24 +0200 Subject: [PATCH] fix(templates): resolve small issues in boilerplate #8994 (#8995) --- .../Components/AppInitializer.cs | 6 ++-- .../Settings/SessionsSection.razor.cs | 2 +- .../Boilerplate.Client.Core/Scripts/app.ts | 2 ++ .../Boilerplate.Client.Maui/App.xaml.cs | 33 ------------------- .../Boilerplate.Client.Maui.csproj | 5 +-- .../Boilerplate.Client.Maui/MauiProgram.cs | 2 -- .../Program.Services.cs | 2 +- 7 files changed, 9 insertions(+), 43 deletions(-) diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppInitializer.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppInitializer.cs index ac89ff068b..ff0a2c81a6 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppInitializer.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppInitializer.cs @@ -158,15 +158,17 @@ private async Task SetupBodyClasses() await jsRuntime.ApplyBodyElementClasses(cssClasses, cssVariables); } - //#if (signalr == true) protected override async ValueTask DisposeAsync(bool disposing) { + AuthenticationManager.AuthenticationStateChanged -= AuthenticationStateChanged; + + //#if (signalr == true) if (hubConnection is not null) { await hubConnection.DisposeAsync(); } + //#endif await base.DisposeAsync(disposing); } - //#endif } diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor.cs index 97b4dba9fa..dcaf573636 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/SessionsSection.razor.cs @@ -66,7 +66,7 @@ private static string GetImageUrl(string? device) var d = device.ToLowerInvariant(); - if (d.Contains("windows") || d.Contains("win32")) return "windows.png"; + if (d.Contains("win") /*Windows, WinUI, Win32*/) return "windows.png"; if (d.Contains("android")) return "android.png"; diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/app.ts b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/app.ts index 9d48be7649..c30141ce57 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/app.ts +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/app.ts @@ -16,6 +16,8 @@ class App { const registration = await navigator.serviceWorker.ready; if (!registration) return null; const pushManager = registration.pushManager; + if (pushManager == null) + return; let subscription = await pushManager.getSubscription(); if (subscription == null) { subscription = await pushManager.subscribe({ diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/App.xaml.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/App.xaml.cs index 8eb7bdf8ce..4b1c963354 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/App.xaml.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/App.xaml.cs @@ -1,7 +1,4 @@ //+:cnd:noEmit -using Maui.AppStores; -using System.Runtime.InteropServices; - [assembly: XamlCompilation(XamlCompilationOptions.Compile)] namespace Boilerplate.Client.Maui; @@ -11,7 +8,6 @@ public partial class App private readonly Page mainPage; private readonly IExceptionHandler exceptionHandler; private readonly IBitDeviceCoordinator deviceCoordinator; - private readonly IStorageService storageService; public App(MainPage mainPage, IExceptionHandler exceptionHandler, @@ -20,7 +16,6 @@ public App(MainPage mainPage, { this.exceptionHandler = exceptionHandler; this.deviceCoordinator = deviceCoordinator; - this.storageService = storageService; this.mainPage = new NavigationPage(mainPage); InitializeComponent(); @@ -38,38 +33,10 @@ protected async override void OnStart() base.OnStart(); await deviceCoordinator.ApplyTheme(AppInfo.Current.RequestedTheme is AppTheme.Dark); - - await CheckForUpdates(); } catch (Exception exp) { exceptionHandler.Handle(exp); } } - - private async Task CheckForUpdates() - { - await Task.Delay(TimeSpan.FromSeconds(3)); // No rush to check for updates. - - try - { - if (await AppStoreInfo.Current.IsUsingLatestVersionAsync() is false) - { - if (await storageService.GetItem($"{AppInfo.Version}_UpdateFromVersionIsRequested") is not "true") - { - await storageService.SetItem($"{AppInfo.Version}_UpdateFromVersionIsRequested", "true"); - - // It's an opportune moment to request an update. (: - // https://github.com/oscoreio/Maui.AppStoreInfo - if (await App.Current!.Windows.First().Page!.DisplayAlert(AppStrings.NewVersionIsAvailable, AppStrings.UpdateToNewVersion, AppStrings.Yes, AppStrings.No) is true) - { - await AppStoreInfo.Current.OpenApplicationInStoreAsync(); - } - } - } - } - catch (InvalidOperationException) when ((AppPlatform.IsIOS || AppPlatform.IsMacOS) && AppEnvironment.IsDev()) { } - catch (FileNotFoundException) { } - catch (COMException) { } - } } diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Boilerplate.Client.Maui.csproj b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Boilerplate.Client.Maui.csproj index a2975eae5a..9cb1206ba0 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Boilerplate.Client.Maui.csproj +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/Boilerplate.Client.Maui.csproj @@ -16,7 +16,6 @@ com.bitplatform.template - AC87AA5B-4B37-4E52-8468-2D5DF24AF256 1.0 @@ -108,7 +107,7 @@ - + @@ -142,7 +141,6 @@ - @@ -153,7 +151,6 @@ - diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.cs index a4df16f420..0f32b69504 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MauiProgram.cs @@ -1,7 +1,6 @@ //-:cnd:noEmit using Microsoft.Maui.Platform; using Microsoft.Maui.LifecycleEvents; -using Maui.AppStores; //+:cnd:noEmit //#if (notification == true) using Plugin.LocalNotification; @@ -41,7 +40,6 @@ public static MauiApp CreateMauiApp() builder .UseMauiApp() - .UseAppStoreInfo() .Configuration.AddClientConfigurations(); //+:cnd:noEmit diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs index a4bbff7c78..4256b84550 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs @@ -413,6 +413,6 @@ private static void AddSwaggerGen(WebApplicationBuilder builder) /// /// For either Blazor Hybrid web view or localhost in dev environment. /// - [GeneratedRegex(@"^(http|https|app):\/\/(localhost|0\.0\.0\.0|127\.0\.0\.1)(:\d+)?(\/.*)?$")] + [GeneratedRegex(@"^(http|https|app):\/\/(localhost|0\.0\.0\.0|0\.0\.0\.1|127\.0\.0\.1)(:\d+)?(\/.*)?$")] private static partial Regex LocalhostOriginRegex(); }