Avoid missing messages when trying to add event to chunk twice
Change-Id: I98ae8e7a5254e6f93fd2a38498b7f8e173ccd565
This commit is contained in:
parent
00fb32a156
commit
088657168f
@ -213,6 +213,20 @@ internal class TokenChunkEventPersistor @Inject constructor(
|
|||||||
// If it exists, we want to stop here, just link the prevChunk
|
// If it exists, we want to stop here, just link the prevChunk
|
||||||
val existingChunk = existingTimelineEvent?.chunk?.firstOrNull()
|
val existingChunk = existingTimelineEvent?.chunk?.firstOrNull()
|
||||||
if (existingChunk != null) {
|
if (existingChunk != null) {
|
||||||
|
if (existingChunk == currentChunk) {
|
||||||
|
Timber.w("Avoid double insertion of event $eventId, shouldn't happen in an ideal world | " +
|
||||||
|
"direction: $direction.value" +
|
||||||
|
"room: $roomId" +
|
||||||
|
"chunk: ${existingChunk.identifier()}" +
|
||||||
|
"eventId: $eventId" +
|
||||||
|
"caughtByOldCheck ${((if (direction == PaginationDirection.BACKWARDS) currentChunk.nextChunk else currentChunk.prevChunk) == existingChunk)}" +
|
||||||
|
"caughtByOldBackwardCheck ${(currentChunk.nextChunk == existingChunk)}" +
|
||||||
|
"caughtByOldForwardCheck ${(currentChunk.prevChunk == existingChunk)}"
|
||||||
|
)
|
||||||
|
// No idea why this happens, but if it does, we don't want to throw away all the other events
|
||||||
|
// (or even link chunks to themselves)
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
val alreadyLinkedNext = currentChunk.doesNextChunksVerifyCondition { it == existingChunk }
|
val alreadyLinkedNext = currentChunk.doesNextChunksVerifyCondition { it == existingChunk }
|
||||||
val alreadyLinkedPrev = currentChunk.doesPrevChunksVerifyCondition { it == existingChunk }
|
val alreadyLinkedPrev = currentChunk.doesPrevChunksVerifyCondition { it == existingChunk }
|
||||||
if (alreadyLinkedNext || alreadyLinkedPrev) {
|
if (alreadyLinkedNext || alreadyLinkedPrev) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user