mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Timeline: fix double link issue when server is messed up...
This commit is contained in:
parent
52df50a686
commit
8c0b2a6704
@ -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 New Issue
Block a user