diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailApiHelper.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailApiHelper.kt index 2001f9ba6..e3ad7644d 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailApiHelper.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/gmail/GmailApiHelper.kt @@ -768,7 +768,8 @@ class GmailApiHelper { .users() .history() .list(DEFAULT_USER_ID) - .setStartHistoryId(historyId).apply { + .setStartHistoryId(historyId) + .apply { if (!localFolder.isAll) { labelId = localFolder.fullName } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/MessageDao.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/MessageDao.kt index 35edc063a..735e946e2 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/MessageDao.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/MessageDao.kt @@ -251,9 +251,9 @@ abstract class MessageDao : BaseDao { @Query( "SELECT * FROM messages " + - "WHERE account = :account AND folder = :folder AND is_visible = 1 ORDER BY thread_id DESC LIMIT 1" + "WHERE account = :account AND is_visible = 1 ORDER BY thread_id DESC LIMIT 1" ) - abstract suspend fun getNewestThread(account: String?, folder: String?): MessageEntity? + abstract suspend fun getNewestThread(account: String?): MessageEntity? @Query("SELECT max(uid) FROM messages WHERE account = :account AND folder = :folder") abstract suspend fun getLastUIDOfMsgForLabelSuspend(account: String?, folder: String?): Int? @@ -434,7 +434,7 @@ abstract class MessageDao : BaseDao { @Query("DELETE FROM messages WHERE account = :account AND folder = :folder AND thread_id = :threadId AND is_visible = 0") abstract suspend fun clearCacheForGmailThread(account: String?, folder: String, threadId: Long) - @Query("DELETE FROM messages WHERE account = :account AND folder = :folder AND thread_id IN (:threadIdList)") + @Query("DELETE FROM messages WHERE account = :account AND folder = :folder AND thread_id IN (:threadIdList) AND is_visible = 0") abstract suspend fun deleteCacheForGmailThreads( account: String?, folder: String, @@ -446,7 +446,7 @@ abstract class MessageDao : BaseDao { && accountEntity.useAPI && accountEntity.useConversationMode ) { - getNewestThread(accountEntity.email, folder) + getNewestThread(accountEntity.email) } else { getNewestMsg(accountEntity.email, folder) } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt index c1ab8d3eb..0fc5d28cb 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt @@ -302,7 +302,8 @@ class DraftViewModel( ).copy( state = MessageState.PENDING_UPLOADING_DRAFT.value, threadId = gmailThreadId, - labelIds = GmailApiHelper.LABEL_DRAFT + labelIds = GmailApiHelper.LABEL_DRAFT, + isVisible = false ) val id = roomDatabase.msgDao().insertSuspend(newDraftMessageEntity) return@withContext newDraftMessageEntity.copy( 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 88c5d49ab..1e52c3e85 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 @@ -561,10 +561,16 @@ class MessagesListFragment : BaseFragment(), ListPr } private fun isItSyncOrCachedFolder(localFolder: LocalFolder?): Boolean { + val checkDrafts = if (account?.useConversationMode == true) { + false + } else { + isDraftsFolder + } + return localFolder?.fullName.equals( JavaEmailConstants.FOLDER_INBOX, ignoreCase = true - ) || isOutboxFolder || isDraftsFolder + ) || isOutboxFolder || checkDrafts } /** @@ -903,7 +909,7 @@ class MessagesListFragment : BaseFragment(), ListPr msgsViewModel.changeMsgsState( ids = ids, localFolder = it, - newMsgState = if (it.isDrafts) { + newMsgState = if (account?.useConversationMode == false && it.isDrafts) { MessageState.PENDING_DELETING_DRAFT } else { MessageState.PENDING_DELETING diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MsgsPagedListAdapter.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MsgsPagedListAdapter.kt index 8735dd4e6..4b33a6080 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MsgsPagedListAdapter.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/MsgsPagedListAdapter.kt @@ -243,10 +243,14 @@ class MsgsPagedListAdapter(private val onMessageClickListener: OnMessageClickLis messageEntity.getThreadSpannableString(context).let { spannableString -> SpannableStringBuilder(senderAddress).apply { if (spannableString.isNotEmpty()) { - if (spannableString.startsWith("(")) { - append(" ") - } else { - append(", ") + when { + spannableString.startsWith("(") -> { + append(" ") + } + + senderAddress.isNotEmpty() -> { + append(", ") + } } } append(spannableString)