Change K9BackendFolder.getMoreMessages() to use MessageStore
This commit is contained in:
parent
3336fd3ed3
commit
7dc4b6dd71
3 changed files with 16 additions and 9 deletions
|
@ -20,5 +20,6 @@ interface FolderDetailsAccessor {
|
|||
val notifyClass: FolderClass
|
||||
val pushClass: FolderClass
|
||||
val visibleLimit: Int
|
||||
val moreMessages: MoreMessages
|
||||
val messageCount: Int
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.fsck.k9.backend.api.BackendFolder.MoreMessages
|
|||
import com.fsck.k9.mail.Flag
|
||||
import com.fsck.k9.mail.Message
|
||||
import java.util.Date
|
||||
import com.fsck.k9.mailstore.MoreMessages as StoreMoreMessages
|
||||
|
||||
class K9BackendFolder(
|
||||
private val localStore: LocalStore,
|
||||
|
@ -61,8 +62,9 @@ class K9BackendFolder(
|
|||
}
|
||||
|
||||
override fun getMoreMessages(): MoreMessages {
|
||||
val moreMessages = database.getString(column = "more_messages") ?: "unknown"
|
||||
return moreMessages.toMoreMessages()
|
||||
return messageStore.getFolder(folderId) { folder ->
|
||||
folder.moreMessages.toMoreMessages()
|
||||
} ?: MoreMessages.UNKNOWN
|
||||
}
|
||||
|
||||
override fun setMoreMessages(moreMessages: MoreMessages) {
|
||||
|
@ -330,11 +332,10 @@ class K9BackendFolder(
|
|||
}
|
||||
}
|
||||
|
||||
private fun String.toMoreMessages(): MoreMessages = when (this) {
|
||||
"unknown" -> MoreMessages.UNKNOWN
|
||||
"false" -> MoreMessages.FALSE
|
||||
"true" -> MoreMessages.TRUE
|
||||
else -> throw AssertionError("Unknown value for MoreMessages: $this")
|
||||
private fun StoreMoreMessages.toMoreMessages(): MoreMessages = when (this) {
|
||||
StoreMoreMessages.UNKNOWN -> MoreMessages.UNKNOWN
|
||||
StoreMoreMessages.FALSE -> MoreMessages.FALSE
|
||||
StoreMoreMessages.TRUE -> MoreMessages.TRUE
|
||||
}
|
||||
|
||||
private fun MoreMessages.toDatabaseValue(): String = when (this) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.fsck.k9.mail.FolderType
|
|||
import com.fsck.k9.mailstore.FolderDetailsAccessor
|
||||
import com.fsck.k9.mailstore.FolderMapper
|
||||
import com.fsck.k9.mailstore.LockableDatabase
|
||||
import com.fsck.k9.mailstore.MoreMessages
|
||||
import com.fsck.k9.mailstore.toFolderType
|
||||
|
||||
internal class RetrieveFolderOperations(private val lockableDatabase: LockableDatabase) {
|
||||
|
@ -161,8 +162,11 @@ private class CursorFolderAccessor(val cursor: Cursor) : FolderDetailsAccessor {
|
|||
override val visibleLimit: Int
|
||||
get() = cursor.getInt(11)
|
||||
|
||||
override val moreMessages: MoreMessages
|
||||
get() = MoreMessages.fromDatabaseName(cursor.getString(12))
|
||||
|
||||
override val messageCount: Int
|
||||
get() = cursor.getInt(12)
|
||||
get() = cursor.getInt(13)
|
||||
}
|
||||
|
||||
private val FOLDER_COLUMNS = arrayOf(
|
||||
|
@ -177,5 +181,6 @@ private val FOLDER_COLUMNS = arrayOf(
|
|||
"display_class",
|
||||
"notify_class",
|
||||
"push_class",
|
||||
"visible_limit"
|
||||
"visible_limit",
|
||||
"more_messages"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue