Read receipts : fix issues with receipts not being sent

This commit is contained in:
ganfra 2019-02-18 17:41:21 +01:00
parent 5e81fc8dc2
commit 03437885ef
1 changed files with 7 additions and 7 deletions

View File

@ -73,7 +73,7 @@ internal class DefaultSetReadMarkersTask(private val roomAPI: RoomAPI,


private fun updateNotificationCountIfNecessary(roomId: String, eventId: String) { private fun updateNotificationCountIfNecessary(roomId: String, eventId: String) {
monarchy.tryTransactionAsync { realm -> monarchy.tryTransactionAsync { realm ->
val isLatestReceived = EventEntity.latestEvent(realm, eventId)?.eventId == eventId val isLatestReceived = EventEntity.latestEvent(realm, roomId)?.eventId == eventId
if (isLatestReceived) { if (isLatestReceived) {
val roomSummary = RoomSummaryEntity.where(realm, roomId).findFirst() val roomSummary = RoomSummaryEntity.where(realm, roomId).findFirst()
?: return@tryTransactionAsync ?: return@tryTransactionAsync
@ -91,7 +91,7 @@ internal class DefaultSetReadMarkersTask(private val roomAPI: RoomAPI,
val liveChunk = ChunkEntity.findLastLiveChunkFromRoom(it, roomId) val liveChunk = ChunkEntity.findLastLiveChunkFromRoom(it, roomId)
?: return@doWithRealm ?: return@doWithRealm
val readReceiptIndex = liveChunk.events.find(readReceipt.eventId)?.displayIndex val readReceiptIndex = liveChunk.events.find(readReceipt.eventId)?.displayIndex
?: -1 ?: Int.MAX_VALUE
val eventToCheckIndex = liveChunk.events.find(eventId)?.displayIndex ?: -1 val eventToCheckIndex = liveChunk.events.find(eventId)?.displayIndex ?: -1
isEventRead = eventToCheckIndex >= readReceiptIndex isEventRead = eventToCheckIndex >= readReceiptIndex
} }