using named parameters when the same types are used in close proximity
This commit is contained in:
parent
a3c4f56774
commit
f9d2f236a4
@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.matrix.android.sdk.internal.database.query
|
||||
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import org.matrix.android.sdk.api.session.events.model.LocalEcho
|
||||
import org.matrix.android.sdk.internal.database.model.ChunkEntity
|
||||
import org.matrix.android.sdk.internal.database.model.ReadMarkerEntity
|
||||
import org.matrix.android.sdk.internal.database.model.ReadReceiptEntity
|
||||
import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
|
||||
private const val MARK_OLD_EVENT_AS_READ = true
|
||||
private const val MARK_UNREAD_DUE_TO_FASTLANE = false
|
||||
@ -42,16 +42,18 @@ internal fun isEventRead(realmConfiguration: RealmConfiguration,
|
||||
val liveChunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomId) ?: return@use
|
||||
val eventToCheck = liveChunk.timelineEvents.find(eventId)
|
||||
isEventRead = when {
|
||||
eventToCheck == null -> handleMissingEvent(realm, liveChunk, roomId, userId, eventId)
|
||||
eventToCheck == null -> handleMissingEvent(
|
||||
realm = realm,
|
||||
latestChunkEntity = liveChunk,
|
||||
roomId = roomId,
|
||||
userId = userId,
|
||||
eventId = eventId
|
||||
)
|
||||
eventToCheck.root?.sender == userId -> true
|
||||
else -> {
|
||||
val readReceipt = ReadReceiptEntity.where(realm, roomId, userId).findFirst()
|
||||
?: return@use
|
||||
val readReceiptIndex = liveChunk.timelineEvents.find(readReceipt.eventId)?.displayIndex
|
||||
?: Int.MIN_VALUE
|
||||
val eventToCheckIndex = eventToCheck.displayIndex
|
||||
|
||||
eventToCheckIndex <= readReceiptIndex
|
||||
else -> {
|
||||
val readReceipt = ReadReceiptEntity.where(realm, roomId, userId).findFirst() ?: return@use
|
||||
val readReceiptIndex = liveChunk.timelineEvents.find(readReceipt.eventId)?.displayIndex ?: Int.MIN_VALUE
|
||||
eventToCheck.displayIndex <= readReceiptIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,8 +74,8 @@ private fun Realm.doesEventExistInChunkHistory(eventId: String): Boolean {
|
||||
return ChunkEntity.findIncludingEvent(this, eventId) != null
|
||||
}
|
||||
|
||||
private fun Realm.hasReadReceiptInLatestChunk(latestChunkEntity: ChunkEntity, roomId: String, userId: String) : Boolean {
|
||||
return ReadReceiptEntity.where(this, roomId, userId).findFirst()?.let {
|
||||
private fun Realm.hasReadReceiptInLatestChunk(latestChunkEntity: ChunkEntity, roomId: String, userId: String): Boolean {
|
||||
return ReadReceiptEntity.where(this, roomId = roomId, userId = userId).findFirst()?.let {
|
||||
latestChunkEntity.timelineEvents.find(it.eventId)
|
||||
} != null
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user