mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +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 ->
|
?.let { readReceiptContent ->
|
||||||
realm.executeTransactionAsync {
|
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) {
|
fun handle(realm: Realm, roomId: String, content: ReadReceiptContent?, isInitialSync: Boolean) {
|
||||||
if (content == null) {
|
content ?: return
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
handleReadReceiptContent(realm, roomId, content, isInitialSync)
|
handleReadReceiptContent(realm, roomId, content, isInitialSync)
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
|
@ -94,9 +93,13 @@ internal class ReadReceiptHandler @Inject constructor(
|
||||||
// First check if we have data from init sync to handle
|
// First check if we have data from init sync to handle
|
||||||
getContentFromInitSync(roomId)?.let {
|
getContentFromInitSync(roomId)?.let {
|
||||||
Timber.w("INIT_SYNC Insert during incremental sync RR for room $roomId")
|
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) {
|
for ((eventId, receiptDict) in content) {
|
||||||
val userIdsDict = receiptDict[READ_KEY] ?: continue
|
val userIdsDict = receiptDict[READ_KEY] ?: continue
|
||||||
val readReceiptsSummary = ReadReceiptsSummaryEntity.where(realm, eventId).findFirst()
|
val readReceiptsSummary = ReadReceiptsSummaryEntity.where(realm, eventId).findFirst()
|
||||||
|
|
Loading…
Reference in a new issue