Dispatch WebView2 runtime toast notification on UI thread (#811)
This commit is contained in:
@@ -29,6 +29,7 @@ public static class CoreUWPContainerSetup
|
||||
services.AddTransient<IFileService, FileService>();
|
||||
services.AddTransient<IStoreRatingService, StoreRatingService>();
|
||||
services.AddTransient<IKeyPressService, KeyPressService>();
|
||||
services.AddTransient<IWebView2RuntimeValidatorService, WebView2RuntimeValidatorService>();
|
||||
services.AddTransient<INotificationBuilder, NotificationBuilder>();
|
||||
services.AddSingleton<ICalendarReminderServer, CalendarReminderServer>();
|
||||
services.AddTransient<IClipboardService, ClipboardService>();
|
||||
|
||||
@@ -252,6 +252,18 @@ public class NotificationBuilder : INotificationBuilder
|
||||
builder.Show();
|
||||
}
|
||||
|
||||
public void CreateWebView2RuntimeMissingNotification()
|
||||
{
|
||||
var builder = new ToastContentBuilder();
|
||||
builder.SetToastScenario(ToastScenario.Default);
|
||||
|
||||
builder.AddText(Translator.Exception_WebView2RuntimeMissing_Title);
|
||||
builder.AddText(Translator.Exception_WebView2RuntimeMissing_Message);
|
||||
|
||||
builder.AddButton(GetDismissButton());
|
||||
builder.Show();
|
||||
}
|
||||
|
||||
public Task CreateCalendarReminderNotificationAsync(CalendarItem calendarItem, long reminderDurationInSeconds)
|
||||
{
|
||||
if (calendarItem == null)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Serilog;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Mail.WinUI.Services;
|
||||
|
||||
public class WebView2RuntimeValidatorService : IWebView2RuntimeValidatorService
|
||||
{
|
||||
public Task<bool> IsRuntimeAvailableAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var version = CoreWebView2Environment.GetAvailableBrowserVersionString();
|
||||
var hasRuntime = !string.IsNullOrWhiteSpace(version);
|
||||
|
||||
return Task.FromResult(hasRuntime);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "WebView2 runtime validation failed.");
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user