Realm-kotlin: implements equals where needed as objects are frozen now
This commit is contained in:
parent
ca4ed5c822
commit
7527693a05
@ -50,6 +50,20 @@ internal class ChunkEntity : RealmObject {
|
||||
|
||||
// If true, then this chunk was previously a last forward chunk
|
||||
fun hasBeenALastForwardChunk() = nextToken == null && !isLastForward
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as ChunkEntity
|
||||
|
||||
if (chunkId != other.chunkId) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return chunkId.hashCode()
|
||||
}
|
||||
|
||||
companion object
|
||||
}
|
||||
|
@ -26,5 +26,22 @@ internal class ReadReceiptEntity : RealmObject {
|
||||
var userId: String = ""
|
||||
var originServerTs: Double = 0.0
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as ReadReceiptEntity
|
||||
|
||||
if (primaryKey != other.primaryKey) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return primaryKey.hashCode()
|
||||
}
|
||||
|
||||
companion object
|
||||
|
||||
|
||||
}
|
||||
|
@ -32,13 +32,27 @@ internal class TimelineEventEntity : RealmObject {
|
||||
var senderName: String? = null
|
||||
var isUniqueDisplayName: Boolean = false
|
||||
var senderAvatar: String? = null
|
||||
var senderMembershipEventId: String? = null
|
||||
|
||||
// ownedByThreadChunk indicates that the current TimelineEventEntity belongs
|
||||
// to a thread chunk and is a temporarily event.
|
||||
var ownedByThreadChunk: Boolean = false
|
||||
var readReceipts: ReadReceiptsSummaryEntity? = null
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as TimelineEventEntity
|
||||
|
||||
if (localId != other.localId) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return localId.hashCode()
|
||||
}
|
||||
|
||||
companion object
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun latestSyncedEventId(realm: TypedRealm, roomId: String): String? =
|
||||
private fun latestSyncedEventId(realm: TypedRealm, roomId: String): String? =
|
||||
TimelineEventEntity.latestEvent(realm, roomId = roomId, includesSending = false)?.eventId
|
||||
|
||||
private suspend fun updateDatabase(roomId: String, markers: Map<String, String>, shouldUpdateRoomSummary: Boolean) {
|
||||
|
@ -21,6 +21,7 @@ import io.realm.kotlin.UpdatePolicy
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.internal.database.model.ReadReceiptEntity
|
||||
import org.matrix.android.sdk.internal.database.model.ReadReceiptsSummaryEntity
|
||||
import org.matrix.android.sdk.internal.database.query.createUnmanaged
|
||||
import org.matrix.android.sdk.internal.database.query.getOrCreate
|
||||
import org.matrix.android.sdk.internal.database.query.where
|
||||
import org.matrix.android.sdk.internal.session.sync.RoomSyncEphemeralTemporaryStore
|
||||
@ -100,12 +101,7 @@ internal class ReadReceiptHandler @Inject constructor(
|
||||
}
|
||||
for ((userId, paramsDict) in userIdsDict) {
|
||||
val ts = paramsDict[TIMESTAMP_KEY] ?: 0.0
|
||||
val receiptEntity = ReadReceiptEntity().apply {
|
||||
this.roomId = roomId
|
||||
this.eventId = eventId
|
||||
this.userId = userId
|
||||
this.originServerTs = ts
|
||||
}
|
||||
val receiptEntity = ReadReceiptEntity.createUnmanaged(roomId, eventId, userId, ts)
|
||||
readReceiptsSummary.readReceipts.add(receiptEntity)
|
||||
}
|
||||
realm.copyToRealm(readReceiptsSummary, updatePolicy = UpdatePolicy.ALL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user