Merge pull request #2077 from Flow-Launcher/fix_win_update_notification_error

Release 1.14.1
This commit is contained in:
Jeremy Wu 2023-04-21 09:44:03 +10:00 committed by GitHub
commit 3b478b57fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 11 deletions

View file

@ -21,6 +21,7 @@ Google
Customise
UWP
uwp
Uwp
Bokmal
Bokm
uninstallation
@ -88,3 +89,8 @@ Noresult
wpftk
mkv
flac
IPublic
keyevent
KListener
requery
vkcode

View file

@ -115,3 +115,6 @@
#http/https
(?:\b(?:https?|ftp|file)://)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]
# UWP
[Uu][Ww][Pp]

View file

@ -1,7 +1,9 @@
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System.IO;
using System.Windows;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
@ -17,8 +19,16 @@ namespace Flow.Launcher
ToastNotificationManagerCompat.Uninstall();
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
public static void Show(string title, string subTitle, string iconPath = null)
{
Application.Current.Dispatcher.Invoke(() =>
{
ShowInternal(title, subTitle, iconPath);
});
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
private static void ShowInternal(string title, string subTitle, string iconPath = null)
{
// Handle notification for win7/8/early win10
if (legacy)
@ -32,11 +42,33 @@ namespace Flow.Launcher
? Path.Combine(Constant.ProgramDirectory, "Images\\app.png")
: iconPath;
new ToastContentBuilder()
.AddText(title, hintMaxLines: 1)
.AddText(subTitle)
.AddAppLogoOverride(new Uri(Icon))
.Show();
try
{
new ToastContentBuilder()
.AddText(title, hintMaxLines: 1)
.AddText(subTitle)
.AddAppLogoOverride(new Uri(Icon))
.Show();
}
catch (InvalidOperationException e)
{
// Temporary fix for the Windows 11 notification issue
// Possibly from 22621.1413 or 22621.1485, judging by post time of #2024
Log.Exception("Flow.Launcher.Notification|Notification InvalidOperationException Error", e);
if (Environment.OSVersion.Version.Build >= 22621)
{
return;
}
else
{
throw;
}
}
catch (Exception e)
{
Log.Exception("Flow.Launcher.Notification|Notification Error", e);
throw;
}
}
private static void LegacyShow(string title, string subTitle, string iconPath)

View file

@ -68,6 +68,7 @@ namespace Flow.Launcher
UpdateManager.RestartApp(Constant.ApplicationFileName);
}
[Obsolete("Typo")]
public void RestarApp() => RestartApp();
public void ShowMainWindow() => _mainVM.Show();
@ -92,10 +93,7 @@ namespace Flow.Launcher
public void ShowMsg(string title, string subTitle, string iconPath, bool useMainWindowAsOwner = true)
{
Application.Current.Dispatcher.Invoke(() =>
{
Notification.Show(title, subTitle, iconPath);
});
Notification.Show(title, subTitle, iconPath);
}
public void OpenSettingDialog()

View file

@ -1,4 +1,4 @@
version: '1.14.0.{build}'
version: '1.14.1.{build}'
init:
- ps: |