Skip to content

Commit 22af2cc

Browse files
committed
Merge branch 'andrewleader/notif-settings-fix' into andrewleader/notif-settingsfix-with-cleanup
2 parents 2ea5894 + f092ea5 commit 22af2cc

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Microsoft.Toolkit.Uwp.Notifications/Toasts/Compat/Desktop/Win32AppInfo.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ public static Win32AppInfo Get()
9999
if (IsAlphaBitmap(bmp, out var bmpData))
100100
{
101101
var alphaBitmap = GetAlphaBitmapFromBitmapData(bmpData);
102-
iconPath = SaveIconToAppPath(alphaBitmap, appId);
102+
iconPath = SaveIconToAppPath(alphaBitmap, aumid);
103103
}
104104
else
105105
{
106-
iconPath = SaveIconToAppPath(bmp, appId);
106+
iconPath = SaveIconToAppPath(bmp, aumid);
107107
}
108108
}
109109
catch
@@ -129,7 +129,7 @@ public static Win32AppInfo Get()
129129
if (string.IsNullOrWhiteSpace(iconPath))
130130
{
131131
// We use the one from the process
132-
iconPath = ExtractAndObtainIconFromCurrentProcess(process, appId);
132+
iconPath = ExtractAndObtainIconFromCurrentProcess(process, aumid);
133133
}
134134

135135
return new Win32AppInfo()
@@ -163,12 +163,12 @@ private static string GetDisplayNameFromCurrentProcess(Process process)
163163
return process.ProcessName;
164164
}
165165

166-
private static string ExtractAndObtainIconFromCurrentProcess(Process process, string appId)
166+
private static string ExtractAndObtainIconFromCurrentProcess(Process process, string aumid)
167167
{
168-
return ExtractAndObtainIconFromPath(process.MainModule.FileName, appId);
168+
return ExtractAndObtainIconFromPath(process.MainModule.FileName, aumid);
169169
}
170170

171-
private static string ExtractAndObtainIconFromPath(string pathToExtract, string appId)
171+
private static string ExtractAndObtainIconFromPath(string pathToExtract, string aumid)
172172
{
173173
try
174174
{
@@ -177,7 +177,7 @@ private static string ExtractAndObtainIconFromPath(string pathToExtract, string
177177

178178
using (var bmp = icon.ToBitmap())
179179
{
180-
return SaveIconToAppPath(bmp, appId);
180+
return SaveIconToAppPath(bmp, aumid);
181181
}
182182
}
183183
catch
@@ -186,11 +186,11 @@ private static string ExtractAndObtainIconFromPath(string pathToExtract, string
186186
}
187187
}
188188

189-
private static string SaveIconToAppPath(Bitmap bitmap, string appId)
189+
private static string SaveIconToAppPath(Bitmap bitmap, string aumid)
190190
{
191191
try
192192
{
193-
var path = Path.Combine(GetAppDataFolderPath(appId), "Icon.png");
193+
var path = Path.Combine(GetAppDataFolderPath(aumid), "Icon.png");
194194

195195
// Ensure the directories exist
196196
Directory.CreateDirectory(Path.GetDirectoryName(path));
@@ -209,9 +209,9 @@ private static string SaveIconToAppPath(Bitmap bitmap, string appId)
209209
/// Gets the app data folder path within the ToastNotificationManagerCompat folder, used for storing icon assets and any additional data.
210210
/// </summary>
211211
/// <returns>Returns a string of the absolute folder path.</returns>
212-
public static string GetAppDataFolderPath(string appId)
212+
public static string GetAppDataFolderPath(string aumid)
213213
{
214-
string conciseAumid = appId.Contains("\\") ? GenerateGuid(appId) : appId;
214+
string conciseAumid = aumid.Contains('\\') || aumid.Contains('/') ? GenerateGuid(aumid) : aumid;
215215

216216
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "ToastNotificationManagerCompat", "Apps", conciseAumid);
217217
}

Microsoft.Toolkit.Uwp.Notifications/Toasts/Compat/ToastNotificationManagerCompat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public static void Uninstall()
465465
{
466466
// Remove all scheduled notifications (do this first before clearing current notifications)
467467
var notifier = CreateToastNotifier();
468-
foreach (var scheduled in CreateToastNotifier().GetScheduledToastNotifications())
468+
foreach (var scheduled in notifier.GetScheduledToastNotifications())
469469
{
470470
try
471471
{

0 commit comments

Comments
 (0)