mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 11:26:01 +03:00
Timeline: fix double link issue when server is messed up...
This commit is contained in:
parent
52df50a686
commit
8c0b2a6704
1 changed files with 18 additions and 7 deletions
|
@ -128,7 +128,7 @@ internal class TokenChunkEventPersistor @Inject constructor(@SessionDatabase pri
|
|||
roomMemberContentsByUser[stateEvent.stateKey] = stateEvent.content.toModel<RoomMemberContent>()
|
||||
}
|
||||
}
|
||||
run processTimelineEvents@ {
|
||||
run processTimelineEvents@{
|
||||
eventList.forEach { event ->
|
||||
if (event.eventId == null || event.senderId == null) {
|
||||
return@forEach
|
||||
|
@ -139,13 +139,24 @@ internal class TokenChunkEventPersistor @Inject constructor(@SessionDatabase pri
|
|||
// If it exists, we want to stop here, just link the prevChunk
|
||||
val existingChunk = existingTimelineEvent?.chunk?.firstOrNull()
|
||||
if (existingChunk != null) {
|
||||
if (direction == PaginationDirection.BACKWARDS) {
|
||||
when (direction) {
|
||||
PaginationDirection.BACKWARDS -> {
|
||||
if (currentChunk.nextChunk == existingChunk) {
|
||||
Timber.w("Avoid double link, shouldn't happen in an ideal world")
|
||||
} else {
|
||||
currentChunk.prevChunk = existingChunk
|
||||
existingChunk.nextChunk = currentChunk
|
||||
} else if (direction == PaginationDirection.FORWARDS) {
|
||||
}
|
||||
}
|
||||
PaginationDirection.FORWARDS -> {
|
||||
if (currentChunk.prevChunk == existingChunk) {
|
||||
Timber.w("Avoid double link, shouldn't happen in an ideal world")
|
||||
} else {
|
||||
currentChunk.nextChunk = existingChunk
|
||||
existingChunk.prevChunk = currentChunk
|
||||
}
|
||||
}
|
||||
}
|
||||
// Stop processing here
|
||||
return@processTimelineEvents
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue