Merge branch 'master' of github.com:SimpleMobileTools/Simple-SMS-Messenger
This commit is contained in:
commit
16734aa93d
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue