From d428a6ce7a12afe91148afd1ce3eb1da04f74b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Sun, 15 Feb 2026 19:44:07 +0100 Subject: [PATCH] Ignore local calendar applying changes to prevent duplicate operations. --- .../CalendarPageViewModel.cs | 9 ++++++ Wino.Core/Synchronizers/ImapSynchronizer.cs | 30 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Wino.Calendar.ViewModels/CalendarPageViewModel.cs b/Wino.Calendar.ViewModels/CalendarPageViewModel.cs index a8ffb1a7..5d613ecb 100644 --- a/Wino.Calendar.ViewModels/CalendarPageViewModel.cs +++ b/Wino.Calendar.ViewModels/CalendarPageViewModel.cs @@ -963,6 +963,15 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel, base.OnCalendarItemUpdated(calendarItem, source); Debug.WriteLine($"Calendar item updated: {calendarItem.Id}"); + // Local-only calendar operations are persisted immediately without real network I/O. + // Ignore optimistic client updates to prevent applying the same mutation twice. + var isLocalCalendarUpdate = string.IsNullOrWhiteSpace(calendarItem.RemoteEventId) || + calendarItem.RemoteEventId.StartsWith("local-", StringComparison.OrdinalIgnoreCase); + if (isLocalCalendarUpdate && source == CalendarItemUpdateSource.ClientUpdated) + { + return; + } + // Series master events should not be visible on the UI. if (calendarItem.IsRecurringParent) { diff --git a/Wino.Core/Synchronizers/ImapSynchronizer.cs b/Wino.Core/Synchronizers/ImapSynchronizer.cs index 60978d84..61863b8c 100644 --- a/Wino.Core/Synchronizers/ImapSynchronizer.cs +++ b/Wino.Core/Synchronizers/ImapSynchronizer.cs @@ -705,7 +705,10 @@ public class ImapSynchronizer : WinoSynchronizer /// Assigns special folder type for the given local folder. /// If server doesn't support special folders, we can't determine the type. MailKit will throw for GetFolder.