mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-15 18:48:52 +01:00
#591 - More accurate dates and snippets when syncing messages
This commit is contained in:
@@ -41,6 +41,7 @@ import com.moez.QKSMS.util.tryOrNull
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import io.realm.Realm
|
||||
import io.realm.Sort
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@@ -126,6 +127,17 @@ class SyncRepositoryImpl @Inject constructor(
|
||||
conversation?.name = data.name
|
||||
}
|
||||
|
||||
realm.where(Message::class.java)
|
||||
.sort("date", Sort.DESCENDING)
|
||||
.distinctValues("threadId")
|
||||
.findAll()
|
||||
.forEach { message ->
|
||||
val conversation = conversations.firstOrNull { conversation -> conversation.id == message.threadId }
|
||||
conversation?.date = message.date
|
||||
conversation?.snippet = message.getSummary()
|
||||
conversation?.me = message.isMe()
|
||||
}
|
||||
|
||||
realm.insertOrUpdate(conversations)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user