From c88c0fb7114a3389912695550b908dc651cf2db1 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Wed, 9 Apr 2025 16:32:28 +0300 Subject: [PATCH 1/4] Fixed opening messages in 'All Mail' folder. |#2995 --- .../flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt index 05f5b5b80c..e25e1002ab 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt @@ -390,7 +390,7 @@ class ThreadDetailsViewModel( val threadInfo = thread.toThreadInfo(getApplication(), activeAccount, localFolder) - if (!threadInfo.labels.contains(localFolder.fullName)) { + if (!threadInfo.labels.contains(localFolder.fullName) && !localFolder.isAll) { val context: Context = getApplication() throw ThreadNotFoundException(context.getString(R.string.thread_was_deleted_or_moved)) } From 7209c10d42b35cff7200a25c0f54c6a2a43a7861 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Wed, 9 Apr 2025 17:31:00 +0300 Subject: [PATCH 2/4] Disabled keeping long term local cache for 'account.useConversationMode == true'.|#2995 --- .../com/flowcrypt/email/api/email/model/LocalFolder.kt | 3 +++ .../email/ui/activity/fragment/MessagesListFragment.kt | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/LocalFolder.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/LocalFolder.kt index 377f85115e..4ab077cae8 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/LocalFolder.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/LocalFolder.kt @@ -55,6 +55,9 @@ data class LocalFolder( @IgnoredOnParcel val isTrash: Boolean = FoldersManager.FolderType.TRASH == getFolderType() + @IgnoredOnParcel + val isInbox: Boolean = FoldersManager.FolderType.INBOX == getFolderType() + fun getFolderType(): FoldersManager.FolderType? { return FoldersManager.getFolderType(this) } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessagesListFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessagesListFragment.kt index 5202cc3a2b..2f9f8953a5 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessagesListFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessagesListFragment.kt @@ -568,10 +568,9 @@ class MessagesListFragment : BaseFragment(), ListPr isDraftsFolder } - return localFolder?.fullName.equals( - JavaEmailConstants.FOLDER_INBOX, - ignoreCase = true - ) || isOutboxFolder || checkDrafts + return localFolder?.isInbox?.takeIf { + account?.useConversationMode != true + } == true || isOutboxFolder || checkDrafts } /** From 72a2d77872fd396654accc3c3a813093fb12ed93 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Fri, 11 Apr 2025 10:41:40 +0300 Subject: [PATCH 3/4] Fixed synchronization in 'All Mail' folder.|#2995 --- .../api/email/gmail/GmailHistoryHandler.kt | 210 +++++++++++++----- 1 file changed, 149 insertions(+), 61 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailHistoryHandler.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailHistoryHandler.kt index 1ca5b87049..29fa2032b5 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailHistoryHandler.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailHistoryHandler.kt @@ -9,6 +9,7 @@ import android.content.Context import com.flowcrypt.email.R import com.flowcrypt.email.api.email.FoldersManager import com.flowcrypt.email.api.email.gmail.GmailApiHelper.Companion.LABEL_DRAFT +import com.flowcrypt.email.api.email.gmail.GmailApiHelper.Companion.LABEL_SPAM import com.flowcrypt.email.api.email.gmail.GmailApiHelper.Companion.LABEL_TRASH import com.flowcrypt.email.api.email.gmail.GmailApiHelper.Companion.labelsToImapFlags import com.flowcrypt.email.api.email.gmail.api.GmaiAPIMimeMessage @@ -128,10 +129,15 @@ object GmailHistoryHandler { val toBeDeletedLocally = gmailThreadInfoList.filter { !it.labels.contains(localFolder.fullName) }.toSet() + val threadIdsOfForeverDeleted = + threadIdsToBeDeleted - gmailThreadInfoList.map { it.id }.toSet() + roomDatabase.msgDao().deleteByUIDsSuspend( account = accountEntity.email, label = localFolder.fullName, - msgsUID = toBeDeletedLocally.map { Long.MAX_VALUE - it.id.toLongRadix16 }) + msgsUID = toBeDeletedLocally.map { Long.MAX_VALUE - it.id.toLongRadix16 } + + threadIdsOfForeverDeleted.map { Long.MAX_VALUE - it.toLongRadix16 } + ) //need to update the left threads val toBeUpdated = gmailThreadInfoList - toBeDeletedLocally @@ -355,88 +361,170 @@ object GmailHistoryHandler { val updateCandidates = mutableMapOf>() val labelsToBeUpdatedMap = mutableMapOf>() - for (history in historyList) { - history.messagesDeleted?.let { messagesDeleted -> - for (historyMsgDeleted in messagesDeleted) { - newCandidatesMap.remove(historyMsgDeleted.message.uid) - updateCandidates.remove(historyMsgDeleted.message.uid) - deleteCandidates[historyMsgDeleted.message.uid] = historyMsgDeleted.message.threadId + if (localFolder.isAll) { + for (history in historyList) { + history.messagesDeleted?.let { messagesDeleted -> + for (historyMsgDeleted in messagesDeleted) { + newCandidatesMap.remove(historyMsgDeleted.message.uid) + updateCandidates.remove(historyMsgDeleted.message.uid) + deleteCandidates[historyMsgDeleted.message.uid] = historyMsgDeleted.message.threadId + } } - } - history.messagesAdded?.let { messagesAdded -> - for (historyMsgAdded in messagesAdded) { - if (!accountEntity.useConversationMode) { - if (LABEL_DRAFT in (historyMsgAdded.message.labelIds - ?: emptyList()) && !localFolder.isDrafts - ) { - //skip adding drafts to non-Drafts folder - continue + history.messagesAdded?.let { messagesAdded -> + for (historyMsgAdded in messagesAdded) { + if (!accountEntity.useConversationMode) { + if (LABEL_DRAFT in (historyMsgAdded.message.labelIds + ?: emptyList()) && !localFolder.isDrafts + ) { + //skip adding drafts to non-Drafts folder + continue + } } + deleteCandidates.remove(historyMsgAdded.message.uid) + updateCandidates.remove(historyMsgAdded.message.uid) + newCandidatesMap[historyMsgAdded.message.uid] = historyMsgAdded.message } - deleteCandidates.remove(historyMsgAdded.message.uid) - updateCandidates.remove(historyMsgAdded.message.uid) - newCandidatesMap[historyMsgAdded.message.uid] = historyMsgAdded.message } - } - history.labelsRemoved?.let { labelsRemoved -> - for (historyLabelRemoved in labelsRemoved) { - val historyMessageLabelIds = historyLabelRemoved?.message?.labelIds ?: emptyList() - labelsToBeUpdatedMap[historyLabelRemoved.message.uid] = Pair( - historyLabelRemoved.message.threadId, - historyMessageLabelIds.joinToString(LABEL_IDS_SEPARATOR) - ) + history.labelsRemoved?.let { labelsRemoved -> + for (historyLabelRemoved in labelsRemoved) { + if ( + historyLabelRemoved.labelIds?.contains(LABEL_TRASH) == true || + historyLabelRemoved.labelIds?.contains(LABEL_SPAM) == true + ) { + deleteCandidates.remove(historyLabelRemoved.message.uid) + updateCandidates.remove(historyLabelRemoved.message.uid) + newCandidatesMap[historyLabelRemoved.message.uid] = historyLabelRemoved.message + continue + } + + val historyMessageLabelIds = historyLabelRemoved?.message?.labelIds ?: emptyList() + labelsToBeUpdatedMap[historyLabelRemoved.message.uid] = Pair( + historyLabelRemoved.message.threadId, + historyMessageLabelIds.joinToString(LABEL_IDS_SEPARATOR) + ) - if (localFolder.fullName in (historyLabelRemoved.labelIds ?: emptyList())) { - newCandidatesMap.remove(historyLabelRemoved.message.uid) - updateCandidates.remove(historyLabelRemoved.message.uid) - deleteCandidates[historyLabelRemoved.message.uid] = historyLabelRemoved.message.threadId - continue + val existedFlags = labelsToImapFlags(historyMessageLabelIds) + updateCandidates[historyLabelRemoved.message.uid] = + Pair(historyLabelRemoved.message.threadId, existedFlags) } + } - if (LABEL_TRASH in (historyLabelRemoved.labelIds ?: emptyList())) { - val message = historyLabelRemoved.message - if (localFolder.fullName in historyMessageLabelIds) { - deleteCandidates.remove(message.uid) - updateCandidates.remove(message.uid) - newCandidatesMap[message.uid] = message + history.labelsAdded?.let { labelsAdded -> + for (historyLabelAdded in labelsAdded) { + if ( + historyLabelAdded.labelIds?.contains(LABEL_TRASH) == true || + historyLabelAdded.labelIds?.contains(LABEL_SPAM) == true + ) { + newCandidatesMap.remove(historyLabelAdded.message.uid) + updateCandidates.remove(historyLabelAdded.message.uid) + deleteCandidates[historyLabelAdded.message.uid] = historyLabelAdded.message.threadId continue } - } - val existedFlags = labelsToImapFlags(historyMessageLabelIds) - updateCandidates[historyLabelRemoved.message.uid] = - Pair(historyLabelRemoved.message.threadId, existedFlags) + labelsToBeUpdatedMap[historyLabelAdded.message.uid] = Pair( + historyLabelAdded.message.threadId, + historyLabelAdded.message.labelIds.joinToString(LABEL_IDS_SEPARATOR) + ) + + val existedFlags = labelsToImapFlags(historyLabelAdded.message.labelIds ?: emptyList()) + updateCandidates[historyLabelAdded.message.uid] = + Pair(historyLabelAdded.message.threadId, existedFlags) + } } } + } else { + for (history in historyList) { + history.messagesDeleted?.let { messagesDeleted -> + for (historyMsgDeleted in messagesDeleted) { + newCandidatesMap.remove(historyMsgDeleted.message.uid) + updateCandidates.remove(historyMsgDeleted.message.uid) + deleteCandidates[historyMsgDeleted.message.uid] = historyMsgDeleted.message.threadId + } + } - history.labelsAdded?.let { labelsAdded -> - for (historyLabelAdded in labelsAdded) { - labelsToBeUpdatedMap[historyLabelAdded.message.uid] = Pair( - historyLabelAdded.message.threadId, - historyLabelAdded.message.labelIds.joinToString(LABEL_IDS_SEPARATOR) - ) - if (localFolder.fullName in (historyLabelAdded.labelIds ?: emptyList())) { - deleteCandidates.remove(historyLabelAdded.message.uid) - updateCandidates.remove(historyLabelAdded.message.uid) - newCandidatesMap[historyLabelAdded.message.uid] = historyLabelAdded.message - continue + history.messagesAdded?.let { messagesAdded -> + for (historyMsgAdded in messagesAdded) { + if (!accountEntity.useConversationMode) { + if (LABEL_DRAFT in (historyMsgAdded.message.labelIds + ?: emptyList()) && !localFolder.isDrafts + ) { + //skip adding drafts to non-Drafts folder + continue + } + } + deleteCandidates.remove(historyMsgAdded.message.uid) + updateCandidates.remove(historyMsgAdded.message.uid) + newCandidatesMap[historyMsgAdded.message.uid] = historyMsgAdded.message } + } + + history.labelsRemoved?.let { labelsRemoved -> + for (historyLabelRemoved in labelsRemoved) { + val historyMessageLabelIds = historyLabelRemoved?.message?.labelIds ?: emptyList() + labelsToBeUpdatedMap[historyLabelRemoved.message.uid] = Pair( + historyLabelRemoved.message.threadId, + historyMessageLabelIds.joinToString(LABEL_IDS_SEPARATOR) + ) + + if (localFolder.fullName in (historyLabelRemoved.labelIds ?: emptyList())) { + newCandidatesMap.remove(historyLabelRemoved.message.uid) + updateCandidates.remove(historyLabelRemoved.message.uid) + deleteCandidates[historyLabelRemoved.message.uid] = + historyLabelRemoved.message.threadId + continue + } + + if (LABEL_TRASH in (historyLabelRemoved.labelIds ?: emptyList())) { + val message = historyLabelRemoved.message + if (localFolder.fullName in historyMessageLabelIds) { + deleteCandidates.remove(message.uid) + updateCandidates.remove(message.uid) + newCandidatesMap[message.uid] = message + continue + } + } - if ((historyLabelAdded.labelIds ?: emptyList()).contains(LABEL_TRASH)) { - newCandidatesMap.remove(historyLabelAdded.message.uid) - updateCandidates.remove(historyLabelAdded.message.uid) - deleteCandidates[historyLabelAdded.message.uid] = historyLabelAdded.message.threadId - continue + val existedFlags = labelsToImapFlags(historyMessageLabelIds) + updateCandidates[historyLabelRemoved.message.uid] = + Pair(historyLabelRemoved.message.threadId, existedFlags) } + } - val existedFlags = labelsToImapFlags(historyLabelAdded.message.labelIds ?: emptyList()) - updateCandidates[historyLabelAdded.message.uid] = - Pair(historyLabelAdded.message.threadId, existedFlags) + history.labelsAdded?.let { labelsAdded -> + for (historyLabelAdded in labelsAdded) { + labelsToBeUpdatedMap[historyLabelAdded.message.uid] = Pair( + historyLabelAdded.message.threadId, + historyLabelAdded.message.labelIds.joinToString(LABEL_IDS_SEPARATOR) + ) + if (localFolder.fullName in (historyLabelAdded.labelIds ?: emptyList())) { + deleteCandidates.remove(historyLabelAdded.message.uid) + updateCandidates.remove(historyLabelAdded.message.uid) + newCandidatesMap[historyLabelAdded.message.uid] = historyLabelAdded.message + continue + } + + if ((historyLabelAdded.labelIds ?: emptyList()).contains(LABEL_TRASH)) { + newCandidatesMap.remove(historyLabelAdded.message.uid) + updateCandidates.remove(historyLabelAdded.message.uid) + deleteCandidates[historyLabelAdded.message.uid] = historyLabelAdded.message.threadId + continue + } + + val existedFlags = labelsToImapFlags(historyLabelAdded.message.labelIds ?: emptyList()) + updateCandidates[historyLabelAdded.message.uid] = + Pair(historyLabelAdded.message.threadId, existedFlags) + } } } } + + deleteCandidates.keys.forEach { + //we remove updates here as updating labels doesn't make sense for deleted items + labelsToBeUpdatedMap.remove(it) + } + action.invoke( deleteCandidates, newCandidatesMap, From 29f8c661385c15ac8a28209eb7cad9c850027960 Mon Sep 17 00:00:00 2001 From: denbond7 Date: Fri, 11 Apr 2025 11:49:05 +0300 Subject: [PATCH 4/4] Refactored code --- .../api/email/gmail/GmailHistoryHandler.kt | 162 ++++++------------ 1 file changed, 56 insertions(+), 106 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailHistoryHandler.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailHistoryHandler.kt index 29fa2032b5..83abe6d70a 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailHistoryHandler.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailHistoryHandler.kt @@ -361,34 +361,40 @@ object GmailHistoryHandler { val updateCandidates = mutableMapOf>() val labelsToBeUpdatedMap = mutableMapOf>() - if (localFolder.isAll) { - for (history in historyList) { - history.messagesDeleted?.let { messagesDeleted -> - for (historyMsgDeleted in messagesDeleted) { - newCandidatesMap.remove(historyMsgDeleted.message.uid) - updateCandidates.remove(historyMsgDeleted.message.uid) - deleteCandidates[historyMsgDeleted.message.uid] = historyMsgDeleted.message.threadId - } + for (history in historyList) { + history.messagesDeleted?.let { messagesDeleted -> + for (historyMsgDeleted in messagesDeleted) { + newCandidatesMap.remove(historyMsgDeleted.message.uid) + updateCandidates.remove(historyMsgDeleted.message.uid) + deleteCandidates[historyMsgDeleted.message.uid] = historyMsgDeleted.message.threadId } + } - history.messagesAdded?.let { messagesAdded -> - for (historyMsgAdded in messagesAdded) { - if (!accountEntity.useConversationMode) { - if (LABEL_DRAFT in (historyMsgAdded.message.labelIds - ?: emptyList()) && !localFolder.isDrafts - ) { - //skip adding drafts to non-Drafts folder - continue - } + history.messagesAdded?.let { messagesAdded -> + for (historyMsgAdded in messagesAdded) { + if (!accountEntity.useConversationMode) { + if (LABEL_DRAFT in (historyMsgAdded.message.labelIds + ?: emptyList()) && !localFolder.isDrafts + ) { + //skip adding drafts to non-Drafts folder + continue } - deleteCandidates.remove(historyMsgAdded.message.uid) - updateCandidates.remove(historyMsgAdded.message.uid) - newCandidatesMap[historyMsgAdded.message.uid] = historyMsgAdded.message } + deleteCandidates.remove(historyMsgAdded.message.uid) + updateCandidates.remove(historyMsgAdded.message.uid) + newCandidatesMap[historyMsgAdded.message.uid] = historyMsgAdded.message } + } - history.labelsRemoved?.let { labelsRemoved -> - for (historyLabelRemoved in labelsRemoved) { + history.labelsRemoved?.let { labelsRemoved -> + for (historyLabelRemoved in labelsRemoved) { + val historyMessageLabelIds = historyLabelRemoved?.message?.labelIds ?: emptyList() + labelsToBeUpdatedMap[historyLabelRemoved.message.uid] = Pair( + historyLabelRemoved.message.threadId, + historyMessageLabelIds.joinToString(LABEL_IDS_SEPARATOR) + ) + + if (localFolder.isAll) { if ( historyLabelRemoved.labelIds?.contains(LABEL_TRASH) == true || historyLabelRemoved.labelIds?.contains(LABEL_SPAM) == true @@ -398,76 +404,7 @@ object GmailHistoryHandler { newCandidatesMap[historyLabelRemoved.message.uid] = historyLabelRemoved.message continue } - - val historyMessageLabelIds = historyLabelRemoved?.message?.labelIds ?: emptyList() - labelsToBeUpdatedMap[historyLabelRemoved.message.uid] = Pair( - historyLabelRemoved.message.threadId, - historyMessageLabelIds.joinToString(LABEL_IDS_SEPARATOR) - ) - - val existedFlags = labelsToImapFlags(historyMessageLabelIds) - updateCandidates[historyLabelRemoved.message.uid] = - Pair(historyLabelRemoved.message.threadId, existedFlags) - } - } - - history.labelsAdded?.let { labelsAdded -> - for (historyLabelAdded in labelsAdded) { - if ( - historyLabelAdded.labelIds?.contains(LABEL_TRASH) == true || - historyLabelAdded.labelIds?.contains(LABEL_SPAM) == true - ) { - newCandidatesMap.remove(historyLabelAdded.message.uid) - updateCandidates.remove(historyLabelAdded.message.uid) - deleteCandidates[historyLabelAdded.message.uid] = historyLabelAdded.message.threadId - continue - } - - labelsToBeUpdatedMap[historyLabelAdded.message.uid] = Pair( - historyLabelAdded.message.threadId, - historyLabelAdded.message.labelIds.joinToString(LABEL_IDS_SEPARATOR) - ) - - val existedFlags = labelsToImapFlags(historyLabelAdded.message.labelIds ?: emptyList()) - updateCandidates[historyLabelAdded.message.uid] = - Pair(historyLabelAdded.message.threadId, existedFlags) - } - } - } - } else { - for (history in historyList) { - history.messagesDeleted?.let { messagesDeleted -> - for (historyMsgDeleted in messagesDeleted) { - newCandidatesMap.remove(historyMsgDeleted.message.uid) - updateCandidates.remove(historyMsgDeleted.message.uid) - deleteCandidates[historyMsgDeleted.message.uid] = historyMsgDeleted.message.threadId - } - } - - history.messagesAdded?.let { messagesAdded -> - for (historyMsgAdded in messagesAdded) { - if (!accountEntity.useConversationMode) { - if (LABEL_DRAFT in (historyMsgAdded.message.labelIds - ?: emptyList()) && !localFolder.isDrafts - ) { - //skip adding drafts to non-Drafts folder - continue - } - } - deleteCandidates.remove(historyMsgAdded.message.uid) - updateCandidates.remove(historyMsgAdded.message.uid) - newCandidatesMap[historyMsgAdded.message.uid] = historyMsgAdded.message - } - } - - history.labelsRemoved?.let { labelsRemoved -> - for (historyLabelRemoved in labelsRemoved) { - val historyMessageLabelIds = historyLabelRemoved?.message?.labelIds ?: emptyList() - labelsToBeUpdatedMap[historyLabelRemoved.message.uid] = Pair( - historyLabelRemoved.message.threadId, - historyMessageLabelIds.joinToString(LABEL_IDS_SEPARATOR) - ) - + } else { if (localFolder.fullName in (historyLabelRemoved.labelIds ?: emptyList())) { newCandidatesMap.remove(historyLabelRemoved.message.uid) updateCandidates.remove(historyLabelRemoved.message.uid) @@ -485,19 +422,32 @@ object GmailHistoryHandler { continue } } - - val existedFlags = labelsToImapFlags(historyMessageLabelIds) - updateCandidates[historyLabelRemoved.message.uid] = - Pair(historyLabelRemoved.message.threadId, existedFlags) } + + val existedFlags = labelsToImapFlags(historyMessageLabelIds) + updateCandidates[historyLabelRemoved.message.uid] = + Pair(historyLabelRemoved.message.threadId, existedFlags) } + } - history.labelsAdded?.let { labelsAdded -> - for (historyLabelAdded in labelsAdded) { - labelsToBeUpdatedMap[historyLabelAdded.message.uid] = Pair( - historyLabelAdded.message.threadId, - historyLabelAdded.message.labelIds.joinToString(LABEL_IDS_SEPARATOR) - ) + history.labelsAdded?.let { labelsAdded -> + for (historyLabelAdded in labelsAdded) { + labelsToBeUpdatedMap[historyLabelAdded.message.uid] = Pair( + historyLabelAdded.message.threadId, + historyLabelAdded.message.labelIds.joinToString(LABEL_IDS_SEPARATOR) + ) + + if (localFolder.isAll) { + if ( + historyLabelAdded.labelIds?.contains(LABEL_TRASH) == true || + historyLabelAdded.labelIds?.contains(LABEL_SPAM) == true + ) { + newCandidatesMap.remove(historyLabelAdded.message.uid) + updateCandidates.remove(historyLabelAdded.message.uid) + deleteCandidates[historyLabelAdded.message.uid] = historyLabelAdded.message.threadId + continue + } + } else { if (localFolder.fullName in (historyLabelAdded.labelIds ?: emptyList())) { deleteCandidates.remove(historyLabelAdded.message.uid) updateCandidates.remove(historyLabelAdded.message.uid) @@ -511,11 +461,11 @@ object GmailHistoryHandler { deleteCandidates[historyLabelAdded.message.uid] = historyLabelAdded.message.threadId continue } - - val existedFlags = labelsToImapFlags(historyLabelAdded.message.labelIds ?: emptyList()) - updateCandidates[historyLabelAdded.message.uid] = - Pair(historyLabelAdded.message.threadId, existedFlags) } + + val existedFlags = labelsToImapFlags(historyLabelAdded.message.labelIds ?: emptyList()) + updateCandidates[historyLabelAdded.message.uid] = + Pair(historyLabelAdded.message.threadId, existedFlags) } } }