Handle read-only calendars

This commit is contained in:
Burak Kaan Köse
2026-04-14 17:52:38 +02:00
parent feff929333
commit 0610096b78
14 changed files with 115 additions and 2 deletions
@@ -165,6 +165,13 @@ public class WinoRequestDelegator : IWinoRequestDelegator
if (calendarPreparationRequest == null)
return;
var resolvedCalendar = await ResolveCalendarAsync(calendarPreparationRequest).ConfigureAwait(false);
if (resolvedCalendar?.IsReadOnly == true)
{
_dialogService.ShowReadOnlyCalendarMessage();
return;
}
IRequestBase request = calendarPreparationRequest.Operation switch
{
CalendarSynchronizerOperation.CreateEvent => await CreateCalendarEventRequestAsync(calendarPreparationRequest).ConfigureAwait(false),
@@ -212,6 +219,25 @@ public class WinoRequestDelegator : IWinoRequestDelegator
return new CreateCalendarEventRequest(composeResult, assignedCalendar);
}
private async Task<AccountCalendar> ResolveCalendarAsync(CalendarOperationPreparationRequest calendarPreparationRequest)
{
if (calendarPreparationRequest.Operation == CalendarSynchronizerOperation.CreateEvent)
{
var calendarId = calendarPreparationRequest.ComposeResult?.CalendarId ?? Guid.Empty;
return calendarId == Guid.Empty
? null
: await _calendarService.GetAccountCalendarAsync(calendarId).ConfigureAwait(false);
}
if (calendarPreparationRequest.CalendarItem?.AssignedCalendar is AccountCalendar assignedCalendar)
return assignedCalendar;
var fallbackCalendarId = calendarPreparationRequest.CalendarItem?.CalendarId ?? Guid.Empty;
return fallbackCalendarId == Guid.Empty
? null
: await _calendarService.GetAccountCalendarAsync(fallbackCalendarId).ConfigureAwait(false);
}
private IRequestBase CreateDeclineRequest(CalendarItem calendarItem, string responseMessage)
{
// For Outlook accounts, declined events are deleted by the server after synchronization.