diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/EmailCache.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/EmailCache.kt index d4e6839294fd214dc5e94d2e570f70e75fad4e63..f1ff13198cf139101d592e32d523d107db10d0db 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/EmailCache.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/EmailCache.kt @@ -20,6 +20,7 @@ import android.content.Context import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore +import com.fsck.k9.Account import com.fsck.k9.controller.MessageReference import com.google.gson.Gson import com.google.gson.TypeAdapter @@ -54,7 +55,7 @@ class EmailCache constructor(private val context: Context, private val gson: Gso } suspend fun saveLatestMails(mailList: List) { - if (mailList.size < MAX_CACHE_SIZE || isCacheShown) return + if (isCacheShown) return isCacheShown = true val cachedMailsWithLatest = getLatestMails(mailList) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListLiveData.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListLiveData.kt index 77cb52c9c9a87cf3eaa1299f18cb08391a1a6377..3644e3fa3c626f355d783432db182a4e21ce5fe5 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListLiveData.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListLiveData.kt @@ -25,21 +25,15 @@ class MessageListLiveData( private fun loadMessageListAsync() { coroutineScope.launch(Dispatchers.Main) { - val cachedMessages = withContext(Dispatchers.IO) { - emailCache.getCachedMails() - } - - cachedMessages?.let { + emailCache.getCachedMails()?.let { value = MessageListInfo(it, true) } val messageList = withContext(Dispatchers.IO) { - val result = messageListLoader.getMessageList(config) - emailCache.saveLatestMails(result.messageListItems) - result + messageListLoader.getMessageList(config) } - value = messageList + emailCache.saveLatestMails(messageList.messageListItems) } } diff --git a/app/ui/legacy/src/main/res/layout/message.xml b/app/ui/legacy/src/main/res/layout/message.xml index 37f9cec3994279b8a6dd4ca7b33e91819c405c2a..6c21110d5cecef9f913da05429d3f2e9804c5ddc 100644 --- a/app/ui/legacy/src/main/res/layout/message.xml +++ b/app/ui/legacy/src/main/res/layout/message.xml @@ -41,6 +41,7 @@ the 'message view theme' setting).