Merge pull request #651 from yparitcher/history

refresh sms history based on oldest sms loaded, ignoring mms
This commit is contained in:
Tibor Kaputa 2023-05-19 22:49:21 +02:00 committed by GitHub
commit dd48fa544e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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