Timeline : check isUnlinked before and after merge
This commit is contained in:
parent
0611661c46
commit
683305030a
|
@ -5,6 +5,7 @@
|
||||||
<w>coroutine</w>
|
<w>coroutine</w>
|
||||||
<w>merlins</w>
|
<w>merlins</w>
|
||||||
<w>moshi</w>
|
<w>moshi</w>
|
||||||
|
<w>persistor</w>
|
||||||
<w>synchronizer</w>
|
<w>synchronizer</w>
|
||||||
<w>untimelined</w>
|
<w>untimelined</w>
|
||||||
</words>
|
</words>
|
||||||
|
|
|
@ -2,7 +2,12 @@ package im.vector.matrix.android.internal.session.room.timeline
|
||||||
|
|
||||||
import arrow.core.Try
|
import arrow.core.Try
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import im.vector.matrix.android.internal.database.helper.*
|
import im.vector.matrix.android.internal.database.helper.addAll
|
||||||
|
import im.vector.matrix.android.internal.database.helper.addOrUpdate
|
||||||
|
import im.vector.matrix.android.internal.database.helper.addStateEvents
|
||||||
|
import im.vector.matrix.android.internal.database.helper.deleteOnCascade
|
||||||
|
import im.vector.matrix.android.internal.database.helper.isUnlinked
|
||||||
|
import im.vector.matrix.android.internal.database.helper.merge
|
||||||
import im.vector.matrix.android.internal.database.model.ChunkEntity
|
import im.vector.matrix.android.internal.database.model.ChunkEntity
|
||||||
import im.vector.matrix.android.internal.database.model.RoomEntity
|
import im.vector.matrix.android.internal.database.model.RoomEntity
|
||||||
import im.vector.matrix.android.internal.database.query.create
|
import im.vector.matrix.android.internal.database.query.create
|
||||||
|
@ -47,8 +52,7 @@ internal class TokenChunkEventPersistor(private val monarchy: Monarchy) {
|
||||||
?: ChunkEntity.create(realm, prevToken, nextToken)
|
?: ChunkEntity.create(realm, prevToken, nextToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
val isUnlinked = currentChunk.isUnlinked()
|
currentChunk.addAll(receivedChunk.events, direction, isUnlinked = currentChunk.isUnlinked())
|
||||||
currentChunk.addAll(receivedChunk.events, direction, isUnlinked = isUnlinked)
|
|
||||||
|
|
||||||
// Then we merge chunks if needed
|
// Then we merge chunks if needed
|
||||||
if (currentChunk != prevChunk && prevChunk != null) {
|
if (currentChunk != prevChunk && prevChunk != null) {
|
||||||
|
@ -65,7 +69,7 @@ internal class TokenChunkEventPersistor(private val monarchy: Monarchy) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
roomEntity.addOrUpdate(currentChunk)
|
roomEntity.addOrUpdate(currentChunk)
|
||||||
roomEntity.addStateEvents(receivedChunk.stateEvents, isUnlinked = isUnlinked)
|
roomEntity.addStateEvents(receivedChunk.stateEvents, isUnlinked = currentChunk.isUnlinked())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue