From ad90a9c8f3419e08954310c6aaafecaca74505ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Sat, 15 Mar 2025 15:22:01 +0100 Subject: [PATCH] Fix: Sequence contains no elements while downloading Gmail messages. --- Wino.Core/Synchronizers/GmailSynchronizer.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Wino.Core/Synchronizers/GmailSynchronizer.cs b/Wino.Core/Synchronizers/GmailSynchronizer.cs index 0430930e..69583dab 100644 --- a/Wino.Core/Synchronizers/GmailSynchronizer.cs +++ b/Wino.Core/Synchronizers/GmailSynchronizer.cs @@ -708,13 +708,17 @@ public class GmailSynchronizer : WinoSynchronizer a.Result).Where(a => a?.HistoryId != null).Max(a => a.HistoryId.Value); + var historyIdMessages = batchProcessCallbacks.Select(a => a.Result).Where(a => a?.HistoryId != null); - if (maxHistoryId != 0) + if (historyIdMessages.Any()) { - Account.SynchronizationDeltaIdentifier = await _gmailChangeProcessor.UpdateAccountDeltaSynchronizationIdentifierAsync(Account.Id, maxHistoryId.ToString()).ConfigureAwait(false); - } + var maxHistoryId = batchProcessCallbacks.Select(a => a.Result).Where(a => a?.HistoryId != null).Max(a => a.HistoryId.Value); + if (maxHistoryId != 0) + { + Account.SynchronizationDeltaIdentifier = await _gmailChangeProcessor.UpdateAccountDeltaSynchronizationIdentifierAsync(Account.Id, maxHistoryId.ToString()).ConfigureAwait(false); + } + } } ///