forked from GitHub-Mirror/riotX-android
Read receipts: sort descending by timestamp
This commit is contained in:
parent
39f58d048b
commit
c313ce78cb
@ -17,6 +17,7 @@
|
||||
package im.vector.matrix.android.internal.database.mapper
|
||||
|
||||
import im.vector.matrix.android.api.session.room.model.ReadReceipt
|
||||
import im.vector.matrix.android.internal.database.model.ReadReceiptEntityFields
|
||||
import im.vector.matrix.android.internal.database.model.ReadReceiptsSummaryEntity
|
||||
import im.vector.matrix.android.internal.database.model.UserEntity
|
||||
import im.vector.matrix.android.internal.database.query.where
|
||||
@ -29,11 +30,16 @@ internal class ReadReceiptsSummaryMapper @Inject constructor(@SessionDatabase pr
|
||||
|
||||
fun map(readReceiptsSummaryEntity: ReadReceiptsSummaryEntity): List<ReadReceipt> {
|
||||
return Realm.getInstance(realmConfiguration).use { realm ->
|
||||
readReceiptsSummaryEntity.readReceipts.mapNotNull {
|
||||
val readReceipts = readReceiptsSummaryEntity.readReceipts
|
||||
readReceipts
|
||||
.mapNotNull {
|
||||
val user = UserEntity.where(realm, it.userId).findFirst()
|
||||
?: return@mapNotNull null
|
||||
ReadReceipt(user.asDomain(), it.originServerTs.toLong())
|
||||
}
|
||||
.sortedByDescending {
|
||||
it.originServerTs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user