diff --git a/src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor.cs b/src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor.cs index 58a41f2b63..d8a181b483 100644 --- a/src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI.Extras/Components/DataGrid/BitDataGrid.razor.cs @@ -416,6 +416,12 @@ public async ValueTask DisposeAsync() // The JS side may routinely be gone already if the reason we're disposing is that // the client disconnected. This is not an error. } + catch(JSException ex) + { + // it seems it's safe to just ignore this exception here. + // otherwise it will blow up the MAUI app in a page refresh for example. + Console.WriteLine(ex.Message); + } } private void CloseColumnOptions() diff --git a/src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/BitFileUpload.razor.cs b/src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/BitFileUpload.razor.cs index daed86ab61..6ac051a6f0 100644 --- a/src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/BitFileUpload.razor.cs +++ b/src/BlazorUI/Bit.BlazorUI/Components/Inputs/FileUpload/BitFileUpload.razor.cs @@ -692,6 +692,12 @@ protected virtual async ValueTask DisposeAsync(bool disposing) await _dropZoneRef.DisposeAsync(); } catch (JSDisconnectedException) { } // we can ignore this exception here + catch (JSException ex) + { + // it seems it's safe to just ignore this exception here. + // otherwise it will blow up the MAUI app in a page refresh for example. + Console.WriteLine(ex.Message); + } } if (_dotnetObj is not null) diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Maui/Platforms/Android/MainActivity.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Maui/Platforms/Android/MainActivity.cs index 4370f26922..5f00e79f9a 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Maui/Platforms/Android/MainActivity.cs +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Maui/Platforms/Android/MainActivity.cs @@ -3,7 +3,7 @@ namespace Bit.BlazorUI.Demo.Client.Maui.Platforms.Android; -[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, +[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTask, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] public class MainActivity : MauiAppCompatActivity { 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 4679f7a0f3..8dbce83806 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 b446430326..5431e7660d 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 @@ -419,6 +419,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(); } diff --git a/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Templates/Templates01OverviewPage.razor b/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Templates/Templates01OverviewPage.razor index 8ae6406c41..17df98a396 100644 --- a/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Templates/Templates01OverviewPage.razor +++ b/src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Templates/Templates01OverviewPage.razor @@ -1,5 +1,7 @@ @page "/templates" @page "/templates/overview" +@page "/boilerplate" +@page "/boilerplate/overview" @inherits AppComponentBase