Revert recent change to fix a crash
`readReceiptsSummaryEntity.realm` is null
This commit is contained in:
parent
bff663d4fa
commit
ed80fe517d
|
@ -23,18 +23,23 @@ import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntity
|
||||||
import org.matrix.android.sdk.internal.database.query.where
|
import org.matrix.android.sdk.internal.database.query.where
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class ReadReceiptsSummaryMapper @Inject constructor(private val realmSessionProvider: RealmSessionProvider) {
|
internal class ReadReceiptsSummaryMapper @Inject constructor(
|
||||||
|
private val realmSessionProvider: RealmSessionProvider
|
||||||
|
) {
|
||||||
|
|
||||||
fun map(readReceiptsSummaryEntity: ReadReceiptsSummaryEntity?): List<ReadReceipt> {
|
fun map(readReceiptsSummaryEntity: ReadReceiptsSummaryEntity?): List<ReadReceipt> {
|
||||||
if (readReceiptsSummaryEntity == null) {
|
if (readReceiptsSummaryEntity == null) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
val readReceipts = readReceiptsSummaryEntity.readReceipts
|
val readReceipts = readReceiptsSummaryEntity.readReceipts
|
||||||
return readReceipts
|
|
||||||
|
return realmSessionProvider.withRealm { realm ->
|
||||||
|
readReceipts
|
||||||
.mapNotNull {
|
.mapNotNull {
|
||||||
val roomMember = RoomMemberSummaryEntity.where(readReceiptsSummaryEntity.realm, roomId = it.roomId, userId = it.userId).findFirst()
|
val roomMember = RoomMemberSummaryEntity.where(realm, roomId = it.roomId, userId = it.userId).findFirst()
|
||||||
?: return@mapNotNull null
|
?: return@mapNotNull null
|
||||||
ReadReceipt(roomMember.asDomain(), it.originServerTs.toLong())
|
ReadReceipt(roomMember.asDomain(), it.originServerTs.toLong())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue