Filter reminder snooze options by default reminder

This commit is contained in:
Burak Kaan Köse
2026-02-27 21:57:41 +01:00
parent 0e742c7a8f
commit c942066878
11 changed files with 223 additions and 33 deletions
+38 -3
View File
@@ -215,12 +215,20 @@ public partial class App : WinoApplication,
// Check calendar reminder toast activation first.
if (toastArguments.TryGetValue(Constants.ToastCalendarActionKey, out string calendarAction) &&
calendarAction == Constants.ToastCalendarNavigateAction &&
toastArguments.TryGetValue(Constants.ToastCalendarItemIdKey, out string calendarItemIdString) &&
Guid.TryParse(calendarItemIdString, out Guid calendarItemId))
{
await HandleCalendarToastNavigationAsync(calendarItemId);
return;
if (calendarAction == Constants.ToastCalendarNavigateAction)
{
await HandleCalendarToastNavigationAsync(calendarItemId);
return;
}
if (calendarAction == Constants.ToastCalendarSnoozeAction)
{
await HandleCalendarToastSnoozeAsync(toastArgs, calendarItemId);
return;
}
}
// Check if this is a navigation toast (user clicked the notification).
@@ -267,6 +275,33 @@ public partial class App : WinoApplication,
navigationService.Navigate(WinoPage.EventDetailsPage, target);
}
private async Task HandleCalendarToastSnoozeAsync(AppNotificationActivatedEventArgs toastArgs, Guid calendarItemId)
{
if (!TryGetSnoozeDurationMinutes(toastArgs, out var snoozeDurationMinutes))
return;
var calendarService = Services.GetRequiredService<ICalendarService>();
var snoozedUntilLocal = DateTime.Now.AddMinutes(snoozeDurationMinutes);
await calendarService.SnoozeCalendarItemAsync(calendarItemId, snoozedUntilLocal).ConfigureAwait(false);
}
private static bool TryGetSnoozeDurationMinutes(AppNotificationActivatedEventArgs toastArgs, out int snoozeDurationMinutes)
{
snoozeDurationMinutes = 0;
if (toastArgs.UserInput == null ||
!toastArgs.UserInput.TryGetValue(Constants.ToastCalendarSnoozeDurationInputId, out var selectedValue) ||
selectedValue == null)
{
return false;
}
var selectedText = selectedValue.ToString();
return int.TryParse(selectedText, out snoozeDurationMinutes) && snoozeDurationMinutes > 0;
}
/// <summary>
/// Handles toast notification click for navigation.
/// Creates window if not running, sets up navigation parameter.