folder structure fixes
This commit is contained in:
@@ -96,6 +96,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
||||
|
||||
// Keeping a reference for quick access to the virtual archive folder.
|
||||
private Guid? archiveFolderId;
|
||||
private bool _isFolderStructureChanged;
|
||||
|
||||
public GmailSynchronizer(MailAccount account,
|
||||
IGmailAuthenticator authenticator,
|
||||
@@ -161,6 +162,8 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
||||
|
||||
try
|
||||
{
|
||||
_isFolderStructureChanged = false;
|
||||
|
||||
// Make sure that virtual archive folder exists before all.
|
||||
if (!archiveFolderId.HasValue)
|
||||
await InitializeArchiveFolderAsync().ConfigureAwait(false);
|
||||
@@ -178,6 +181,11 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
||||
throw new GmailServiceDisabledException();
|
||||
}
|
||||
|
||||
if (_isFolderStructureChanged)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new AccountFolderConfigurationUpdated(Account.Id));
|
||||
}
|
||||
|
||||
_logger.Information("Synchronizing folders for {Name} is completed", Account.Name);
|
||||
UpdateSyncProgress(0, 0, "Folders synchronized");
|
||||
|
||||
@@ -696,6 +704,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
||||
};
|
||||
|
||||
await _gmailChangeProcessor.InsertFolderAsync(archiveFolder).ConfigureAwait(false);
|
||||
_isFolderStructureChanged = true;
|
||||
|
||||
// Migration-> User might've already have another special folder for Archive.
|
||||
// We must remove that type assignment.
|
||||
@@ -703,6 +712,11 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
||||
|
||||
var otherArchiveFolders = localFolders.Where(a => a.SpecialFolderType == SpecialFolderType.Archive && a.Id != archiveFolderId.Value).ToList();
|
||||
|
||||
if (otherArchiveFolders.Any())
|
||||
{
|
||||
_isFolderStructureChanged = true;
|
||||
}
|
||||
|
||||
foreach (var otherArchiveFolder in otherArchiveFolders)
|
||||
{
|
||||
otherArchiveFolder.SpecialFolderType = SpecialFolderType.Other;
|
||||
@@ -803,7 +817,7 @@ public class GmailSynchronizer : WinoSynchronizer<IClientServiceRequest, Message
|
||||
|
||||
if (insertedFolders.Any() || deletedFolders.Any() || updatedFolders.Any())
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new AccountFolderConfigurationUpdated(Account.Id));
|
||||
_isFolderStructureChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ public class ImapSynchronizer : WinoSynchronizer<ImapRequest, ImapMessageCreatio
|
||||
private bool _isCalDavDiscoveryAttempted;
|
||||
private readonly IImapCalendarOperationHandler _localCalendarOperationHandler;
|
||||
private readonly IImapCalendarOperationHandler _calDavCalendarOperationHandler;
|
||||
private bool _isFolderStructureChanged;
|
||||
|
||||
public ImapSynchronizer(MailAccount account,
|
||||
IImapChangeProcessor imapChangeProcessor,
|
||||
@@ -557,6 +558,8 @@ public class ImapSynchronizer : WinoSynchronizer<ImapRequest, ImapMessageCreatio
|
||||
|
||||
try
|
||||
{
|
||||
_isFolderStructureChanged = false;
|
||||
|
||||
// Set indeterminate progress initially
|
||||
UpdateSyncProgress(0, 0, "Synchronizing...");
|
||||
|
||||
@@ -565,6 +568,11 @@ public class ImapSynchronizer : WinoSynchronizer<ImapRequest, ImapMessageCreatio
|
||||
if (shouldDoFolderSync)
|
||||
{
|
||||
await SynchronizeFoldersAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (_isFolderStructureChanged)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new AccountFolderConfigurationUpdated(Account.Id));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.Type != MailSynchronizationType.FoldersOnly)
|
||||
@@ -1018,7 +1026,7 @@ public class ImapSynchronizer : WinoSynchronizer<ImapRequest, ImapMessageCreatio
|
||||
|
||||
if (insertedFolders.Any() || deletedFolders.Any() || updatedFolders.Any())
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new AccountFolderConfigurationUpdated(Account.Id));
|
||||
_isFolderStructureChanged = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -41,6 +41,7 @@ using Wino.Core.Requests.Bundles;
|
||||
using Wino.Core.Requests.Calendar;
|
||||
using Wino.Core.Requests.Folder;
|
||||
using Wino.Core.Requests.Mail;
|
||||
using Wino.Messaging.UI;
|
||||
|
||||
namespace Wino.Core.Synchronizers.Mail;
|
||||
|
||||
@@ -112,6 +113,7 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
|
||||
private readonly IOutlookChangeProcessor _outlookChangeProcessor;
|
||||
private readonly GraphServiceClient _graphClient;
|
||||
private readonly IOutlookSynchronizerErrorHandlerFactory _errorHandlingFactory;
|
||||
private bool _isFolderStructureChanged;
|
||||
|
||||
private readonly SemaphoreSlim _concurrentDownloadSemaphore = new(10); // Limit to 10 concurrent downloads
|
||||
|
||||
@@ -990,6 +992,7 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
|
||||
if (IsResourceDeleted(folder.AdditionalData))
|
||||
{
|
||||
await _outlookChangeProcessor.DeleteFolderAsync(Account.Id, folder.Id).ConfigureAwait(false);
|
||||
_isFolderStructureChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1022,6 +1025,7 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
|
||||
item.ShowUnreadCount = item.SpecialFolderType != SpecialFolderType.Deleted || item.SpecialFolderType != SpecialFolderType.Other;
|
||||
|
||||
await _outlookChangeProcessor.InsertFolderAsync(item).ConfigureAwait(false);
|
||||
_isFolderStructureChanged = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1118,6 +1122,8 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
|
||||
|
||||
private async Task SynchronizeFoldersAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
_isFolderStructureChanged = false;
|
||||
|
||||
var specialFolderInfo = await GetSpecialFolderIdsAsync(cancellationToken).ConfigureAwait(false);
|
||||
var graphFolders = await GetDeltaFoldersAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@@ -1128,6 +1134,11 @@ public class OutlookSynchronizer : WinoSynchronizer<RequestInformation, Message,
|
||||
await iterator.IterateAsync();
|
||||
|
||||
await UpdateDeltaSynchronizationIdentifierAsync(iterator.Deltalink).ConfigureAwait(false);
|
||||
|
||||
if (_isFolderStructureChanged)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new AccountFolderConfigurationUpdated(Account.Id));
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> DeserializeGraphBatchResponseAsync<T>(BatchResponseContentCollection collection, string requestId, CancellationToken cancellationToken = default) where T : IParsable, new()
|
||||
|
||||
Reference in New Issue
Block a user