Skip to content

Commit

Permalink
Merge pull request #2077 from Flow-Launcher/fix_win_update_notificati…
Browse files Browse the repository at this point in the history
…on_error

Release 1.14.1
  • Loading branch information
jjw24 authored Apr 20, 2023
2 parents 25dec33 + 42be53c commit 3b478b5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Google
Customise
UWP
uwp
Uwp
Bokmal
Bokm
uninstallation
Expand Down Expand Up @@ -88,3 +89,8 @@ Noresult
wpftk
mkv
flac
IPublic
keyevent
KListener
requery
vkcode
3 changes: 3 additions & 0 deletions .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@

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

# UWP
[Uu][Ww][Pp]
44 changes: 38 additions & 6 deletions Flow.Launcher/Notification.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -17,8 +19,16 @@ internal static void 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)
{
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)
Expand All @@ -32,11 +42,33 @@ public static void Show(string title, string subTitle, string iconPath = null)
? 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)
Expand Down
6 changes: 2 additions & 4 deletions Flow.Launcher/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void RestartApp()
UpdateManager.RestartApp(Constant.ApplicationFileName);
}

[Obsolete("Typo")]
public void RestarApp() => RestartApp();

public void ShowMainWindow() => _mainVM.Show();
Expand All @@ -92,10 +93,7 @@ public void ShowMsg(string title, string subTitle = "", string iconPath = "") =>

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()
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '1.14.0.{build}'
version: '1.14.1.{build}'

init:
- ps: |
Expand Down

0 comments on commit 3b478b5

Please sign in to comment.