mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
Fix double RR issue when optimizing init sync
This commit is contained in:
parent
857bfcb971
commit
ed662d3add
2 changed files with 8 additions and 5 deletions
|
@ -199,7 +199,7 @@ internal class DefaultTimeline(
|
|||
}
|
||||
?.let { readReceiptContent ->
|
||||
realm.executeTransactionAsync {
|
||||
readReceiptHandler.handle(it, roomId, readReceiptContent, true)
|
||||
readReceiptHandler.handle(it, roomId, readReceiptContent, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,9 +56,8 @@ internal class ReadReceiptHandler @Inject constructor(
|
|||
}
|
||||
|
||||
fun handle(realm: Realm, roomId: String, content: ReadReceiptContent?, isInitialSync: Boolean) {
|
||||
if (content == null) {
|
||||
return
|
||||
}
|
||||
content ?: return
|
||||
|
||||
try {
|
||||
handleReadReceiptContent(realm, roomId, content, isInitialSync)
|
||||
} catch (exception: Exception) {
|
||||
|
@ -94,9 +93,13 @@ internal class ReadReceiptHandler @Inject constructor(
|
|||
// First check if we have data from init sync to handle
|
||||
getContentFromInitSync(roomId)?.let {
|
||||
Timber.w("INIT_SYNC Insert during incremental sync RR for room $roomId")
|
||||
initialSyncStrategy(realm, roomId, it)
|
||||
doIncrementalSyncStrategy(realm, roomId, it)
|
||||
}
|
||||
|
||||
doIncrementalSyncStrategy(realm, roomId, content)
|
||||
}
|
||||
|
||||
private fun doIncrementalSyncStrategy(realm: Realm, roomId: String, content: ReadReceiptContent) {
|
||||
for ((eventId, receiptDict) in content) {
|
||||
val userIdsDict = receiptDict[READ_KEY] ?: continue
|
||||
val readReceiptsSummary = ReadReceiptsSummaryEntity.where(realm, eventId).findFirst()
|
||||
|
|
Loading…
Reference in a new issue