Merge branch 'master' of github.com:SimpleMobileTools/Simple-SMS-Messenger

This commit is contained in:
tibbi 2023-05-19 22:54:22 +02:00
commit 16734aa93d
2 changed files with 4 additions and 3 deletions

View File

@ -520,7 +520,8 @@ class ThreadActivity : SimpleActivity() {
return
}
val dateOfFirstItem = messages.first().date
val firstItem = messages.first()
val dateOfFirstItem = firstItem.date
if (oldestMessageDate == dateOfFirstItem) {
allMessagesFetched = true
return
@ -530,12 +531,11 @@ class ThreadActivity : SimpleActivity() {
loadingOlderMessages = true
ensureBackgroundThread {
val firstItem = messages.first()
val olderMessages = getMessages(threadId, true, oldestMessageDate)
.filter { message -> !messages.contains(message) }
messages.addAll(0, olderMessages)
allMessagesFetched = olderMessages.size < MESSAGES_LIMIT || olderMessages.isEmpty()
allMessagesFetched = olderMessages.isEmpty()
threadItems = getThreadItems()
runOnUiThread {

View File

@ -135,6 +135,7 @@ fun Context.getMessages(
.filter { it.participants.isNotEmpty() }
.filterNot { it.isScheduled && it.millis() < System.currentTimeMillis() }
.sortedWith(compareBy<Message> { it.date }.thenBy { it.id })
.takeLast(limit)
.toMutableList() as ArrayList<Message>
return messages