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 3199486a35..1ca5b87049 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 @@ -154,7 +154,9 @@ object GmailHistoryHandler { localFolder = localFolder, threads = uniqueThreadIdList.map { Thread().apply { id = it } }, format = GmailApiHelper.RESPONSE_FORMAT_FULL - ) + ).run { + takeIf { accountEntity.showOnlyEncrypted != true } ?: filter { it.hasPgpThings } + } val threadsToBeAdded = gmailThreadInfoList .filter { it.id !in existingThreadIds } @@ -274,9 +276,7 @@ object GmailHistoryHandler { context, accountEntity, newCandidates.toList(), localFolder ).run { - if (accountEntity.showOnlyEncrypted == true) { - filter { it.hasPgp() } - } else this + takeIf { accountEntity.showOnlyEncrypted != true } ?: filter { it.hasPgp() } } val draftIdsMap = if (localFolder.isDrafts) { diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/sync/SyncDraftsWorker.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/sync/SyncDraftsWorker.kt index 780057dabe..72997b8f53 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/sync/SyncDraftsWorker.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/sync/SyncDraftsWorker.kt @@ -72,7 +72,7 @@ class SyncDraftsWorker(context: Context, params: WorkerParameters) : label = folderDrafts.fullName, msgsList = msgs, isNew = false, - onlyPgpModeEnabled = accountEntity.showOnlyEncrypted ?: false, + onlyPgpModeEnabled = accountEntity.showOnlyEncrypted == true, draftIdsMap = newDrafts.associateBy({ it.message.id }, { it.id }) ) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/service/MessagesNotificationManager.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/service/MessagesNotificationManager.kt index 1e18b2d9e5..e504354bff 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/service/MessagesNotificationManager.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/service/MessagesNotificationManager.kt @@ -105,7 +105,7 @@ class MessagesNotificationManager(context: Context) : CustomNotificationManager( SharedPreferencesHelper.getString( PreferenceManager.getDefaultSharedPreferences(context), Constants.PREF_KEY_MESSAGES_NOTIFICATION_FILTER, "" - ) + ) || account.showOnlyEncrypted == true val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager prepareAndShowMsgGroup(context, account, localFolder, manager, msgs) @@ -170,7 +170,7 @@ class MessagesNotificationManager(context: Context) : CustomNotificationManager( SharedPreferencesHelper.getString( PreferenceManager.getDefaultSharedPreferences(context), Constants.PREF_KEY_MESSAGES_NOTIFICATION_FILTER, "" - ) + ) || account.showOnlyEncrypted == true if (isEncryptedModeEnabled) { var isEncryptedMsgFound = false