Merge pull request #5038 from k9mail/fix_message_list_loading

Don't crash when MessageListLoader couldn't retrieve any Cursors
This commit is contained in:
cketti 2020-11-01 15:36:37 +01:00 committed by GitHub
commit 37c391f596
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,14 +45,19 @@ class MessageListLoader(
.mapNotNull { loadMessageListForAccount(it, config) }
.toTypedArray()
if (cursors.isEmpty()) {
Timber.w("Couldn't get message list")
return MessageListInfo(messageListItems = emptyList(), hasMoreMessages = false)
}
val cursor: Cursor
val uniqueIdColumn: Int
if (cursors.size > 1) {
cursor = MergeCursorWithUniqueId(cursors, getComparator(config))
uniqueIdColumn = cursor.getColumnIndex("_id")
} else {
if (cursors.size == 1) {
cursor = cursors[0]
uniqueIdColumn = MLFProjectionInfo.ID_COLUMN
} else {
cursor = MergeCursorWithUniqueId(cursors, getComparator(config))
uniqueIdColumn = cursor.getColumnIndex("_id")
}
val messageListItems = cursor.use {