forked from GitHub-Mirror/riotX-android
Read receipts : fix issues with receipts not being sent
This commit is contained in:
parent
5e81fc8dc2
commit
03437885ef
@ -56,8 +56,8 @@ internal class DefaultSetReadMarkersTask(private val roomAPI: RoomAPI,
|
|||||||
markers[READ_MARKER] = params.fullyReadEventId
|
markers[READ_MARKER] = params.fullyReadEventId
|
||||||
}
|
}
|
||||||
if (params.readReceiptEventId != null
|
if (params.readReceiptEventId != null
|
||||||
&& MatrixPatterns.isEventId(params.readReceiptEventId)
|
&& MatrixPatterns.isEventId(params.readReceiptEventId)
|
||||||
&& !isEventRead(params.roomId, params.readReceiptEventId)) {
|
&& !isEventRead(params.roomId, params.readReceiptEventId)) {
|
||||||
|
|
||||||
updateNotificationCountIfNecessary(params.roomId, params.readReceiptEventId)
|
updateNotificationCountIfNecessary(params.roomId, params.readReceiptEventId)
|
||||||
markers[READ_RECEIPT] = params.readReceiptEventId
|
markers[READ_RECEIPT] = params.readReceiptEventId
|
||||||
@ -73,10 +73,10 @@ 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
|
||||||
roomSummary.notificationCount = 0
|
roomSummary.notificationCount = 0
|
||||||
roomSummary.highlightCount = 0
|
roomSummary.highlightCount = 0
|
||||||
}
|
}
|
||||||
@ -87,11 +87,11 @@ internal class DefaultSetReadMarkersTask(private val roomAPI: RoomAPI,
|
|||||||
var isEventRead = false
|
var isEventRead = false
|
||||||
monarchy.doWithRealm {
|
monarchy.doWithRealm {
|
||||||
val readReceipt = ReadReceiptEntity.where(it, roomId, credentials.userId).findFirst()
|
val readReceipt = ReadReceiptEntity.where(it, roomId, credentials.userId).findFirst()
|
||||||
?: return@doWithRealm
|
?: return@doWithRealm
|
||||||
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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user