mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix Windows 11 notification error (#2073)
* Fix Windows 11 22H2 (22621) notification error * Fix main thread issue of LegacyShow() * Mark RestarApp() as deprecated
This commit is contained in:
parent
c61d6f791c
commit
04cdfed901
4 changed files with 49 additions and 10 deletions
6
.github/actions/spelling/expect.txt
vendored
6
.github/actions/spelling/expect.txt
vendored
|
|
@ -22,6 +22,7 @@ Google
|
||||||
Customise
|
Customise
|
||||||
UWP
|
UWP
|
||||||
uwp
|
uwp
|
||||||
|
Uwp
|
||||||
Bokmal
|
Bokmal
|
||||||
Bokm
|
Bokm
|
||||||
uninstallation
|
uninstallation
|
||||||
|
|
@ -89,3 +90,8 @@ Noresult
|
||||||
wpftk
|
wpftk
|
||||||
mkv
|
mkv
|
||||||
flac
|
flac
|
||||||
|
IPublic
|
||||||
|
keyevent
|
||||||
|
KListener
|
||||||
|
requery
|
||||||
|
vkcode
|
||||||
|
|
|
||||||
3
.github/actions/spelling/patterns.txt
vendored
3
.github/actions/spelling/patterns.txt
vendored
|
|
@ -115,3 +115,6 @@
|
||||||
|
|
||||||
#http/https
|
#http/https
|
||||||
(?:\b(?:https?|ftp|file)://)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]
|
(?:\b(?:https?|ftp|file)://)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]
|
||||||
|
|
||||||
|
# UWP
|
||||||
|
[Uu][Ww][Pp]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
using Flow.Launcher.Infrastructure;
|
using Flow.Launcher.Infrastructure;
|
||||||
|
using Flow.Launcher.Infrastructure.Logger;
|
||||||
using Microsoft.Toolkit.Uwp.Notifications;
|
using Microsoft.Toolkit.Uwp.Notifications;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
using Windows.Data.Xml.Dom;
|
using Windows.Data.Xml.Dom;
|
||||||
using Windows.UI.Notifications;
|
using Windows.UI.Notifications;
|
||||||
|
|
||||||
|
|
@ -17,8 +19,16 @@ namespace Flow.Launcher
|
||||||
ToastNotificationManagerCompat.Uninstall();
|
ToastNotificationManagerCompat.Uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>")]
|
|
||||||
public static void Show(string title, string subTitle, string iconPath = null)
|
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
|
// Handle notification for win7/8/early win10
|
||||||
if (legacy)
|
if (legacy)
|
||||||
|
|
@ -32,11 +42,33 @@ namespace Flow.Launcher
|
||||||
? Path.Combine(Constant.ProgramDirectory, "Images\\app.png")
|
? Path.Combine(Constant.ProgramDirectory, "Images\\app.png")
|
||||||
: iconPath;
|
: iconPath;
|
||||||
|
|
||||||
new ToastContentBuilder()
|
try
|
||||||
.AddText(title, hintMaxLines: 1)
|
{
|
||||||
.AddText(subTitle)
|
new ToastContentBuilder()
|
||||||
.AddAppLogoOverride(new Uri(Icon))
|
.AddText(title, hintMaxLines: 1)
|
||||||
.Show();
|
.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)
|
private static void LegacyShow(string title, string subTitle, string iconPath)
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ namespace Flow.Launcher
|
||||||
UpdateManager.RestartApp(Constant.ApplicationFileName);
|
UpdateManager.RestartApp(Constant.ApplicationFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Typo")]
|
||||||
public void RestarApp() => RestartApp();
|
public void RestarApp() => RestartApp();
|
||||||
|
|
||||||
public void ShowMainWindow() => _mainVM.Show();
|
public void ShowMainWindow() => _mainVM.Show();
|
||||||
|
|
@ -92,10 +93,7 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
public void ShowMsg(string title, string subTitle, string iconPath, bool useMainWindowAsOwner = true)
|
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()
|
public void OpenSettingDialog()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue