Skip to content

Commit 4411766

Browse files
committed
Fix a possible exception when a "choice" key wasn't found in the toast arguments.
1 parent d133250 commit 4411766

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

NetStalker/NetStalker/ToastNotifications/NotificationChoice.cs

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ public enum NotificationChoice
1313
Show,
1414
Block,
1515
Suppress,
16+
None
1617
}
1718
}

NetStalker/NetStalker/ToastNotifications/ToastAPI.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,18 @@ private async static void Notifications_OnActivated(ToastNotificationActivatedEv
8686
return;
8787
}
8888

89-
if (!Enum.TryParse<NotificationChoice>(args["Choice"], out NotificationChoice NotificationChoice))
89+
if (!args.Contains("Choice"))
9090
{
9191
return; //No choice to select then no action required e.g. body tapped
9292
}
9393

94+
NotificationChoice NotificationChoice = NotificationChoice.None;
95+
96+
if (!Enum.TryParse<NotificationChoice>(args["Choice"], out NotificationChoice))
97+
{
98+
return; //No valid choice, we return
99+
}
100+
94101
switch (Enum.Parse(typeof(NotificationPurpose), args["Action"]))
95102
{
96103
case NotificationPurpose.NotificationsSuppression:

0 commit comments

Comments
 (0)