Skip to content

Commit

Permalink
Fix a possible exception when a "choice" key wasn't found in the toas…
Browse files Browse the repository at this point in the history
…t arguments.
  • Loading branch information
hmz777 committed Jun 1, 2021
1 parent d133250 commit 4411766
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public enum NotificationChoice
Show,
Block,
Suppress,
None
}
}
9 changes: 8 additions & 1 deletion NetStalker/NetStalker/ToastNotifications/ToastAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,18 @@ private async static void Notifications_OnActivated(ToastNotificationActivatedEv
return;
}

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

NotificationChoice NotificationChoice = NotificationChoice.None;

if (!Enum.TryParse<NotificationChoice>(args["Choice"], out NotificationChoice))
{
return; //No valid choice, we return
}

switch (Enum.Parse(typeof(NotificationPurpose), args["Action"]))
{
case NotificationPurpose.NotificationsSuppression:
Expand Down

0 comments on commit 4411766

Please sign in to comment.