Skip to content

Commit

Permalink
fix(templates): resolve small issues in boilerplate #8994 (#8995)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi authored Oct 23, 2024
1 parent 565b70f commit a60d117
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//+:cnd:noEmit
using Maui.AppStores;
using System.Runtime.InteropServices;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

namespace Boilerplate.Client.Maui;
Expand All @@ -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,
Expand All @@ -20,7 +16,6 @@ public App(MainPage mainPage,
{
this.exceptionHandler = exceptionHandler;
this.deviceCoordinator = deviceCoordinator;
this.storageService = storageService;
this.mainPage = new NavigationPage(mainPage);

InitializeComponent();
Expand All @@ -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) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

<!-- App Identifier -->
<ApplicationId>com.bitplatform.template</ApplicationId>
<ApplicationIdGuid>AC87AA5B-4B37-4E52-8468-2D5DF24AF256</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
Expand Down Expand Up @@ -108,7 +107,7 @@
</ItemGroup>

<ItemGroup>

<Using Include="Microsoft.AspNetCore.Components.WebView.Maui" />
<Using Include="Boilerplate.Client.Core.Components.Layout" />
<Using Include="Boilerplate.Client.Core.Components.Pages" />
Expand Down Expand Up @@ -142,7 +141,6 @@
<ItemGroup>
<Content Remove="compilerconfig.json" />
<None Include="compilerconfig.json" />
<Content Remove="Properties\launchSettings.json" />
</ItemGroup>

<ItemGroup>
Expand All @@ -153,7 +151,6 @@
<PackageReference Include="EmbedIO" />
<PackageReference Include="Microsoft.Maui.Controls" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" />
<PackageReference Include="Oscore.Maui.AppStoreInfo" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,7 +40,6 @@ public static MauiApp CreateMauiApp()

builder
.UseMauiApp<App>()
.UseAppStoreInfo()
.Configuration.AddClientConfigurations();

//+:cnd:noEmit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,6 @@ private static void AddSwaggerGen(WebApplicationBuilder builder)
/// <summary>
/// For either Blazor Hybrid web view or localhost in dev environment.
/// </summary>
[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();
}

0 comments on commit a60d117

Please sign in to comment.