mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-16 19:18:52 +01:00
Make sure lastMessage gets assigned when syncing conversation
This commit is contained in:
@@ -368,6 +368,8 @@ class ConversationRepositoryImpl @Inject constructor(
|
||||
?.let { conversation ->
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val contacts = realm.copyFromRealm(realm.where(Contact::class.java).findAll())
|
||||
val lastMessage = realm.where(Message::class.java).equalTo("threadId", threadId)
|
||||
.sort("date", Sort.DESCENDING).findFirst()?.let(realm::copyFromRealm)
|
||||
|
||||
val recipients = conversation.recipients
|
||||
.map { recipient -> recipient.id }
|
||||
@@ -387,6 +389,7 @@ class ConversationRepositoryImpl @Inject constructor(
|
||||
|
||||
conversation.recipients.clear()
|
||||
conversation.recipients.addAll(recipients)
|
||||
conversation.lastMessage = lastMessage
|
||||
realm.executeTransaction { it.insertOrUpdate(conversation) }
|
||||
realm.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user