folder structure fixes

This commit is contained in:
Burak Kaan Köse
2026-03-01 16:23:28 +01:00
parent f35a4333f9
commit bdd32786d6
5 changed files with 78 additions and 17 deletions
+15 -1
View File
@@ -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;
}
}