mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-18 13:00:18 +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>()
|
roomMemberContentsByUser[stateEvent.stateKey] = stateEvent.content.toModel<RoomMemberContent>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run processTimelineEvents@ {
|
run processTimelineEvents@{
|
||||||
eventList.forEach { event ->
|
eventList.forEach { event ->
|
||||||
if (event.eventId == null || event.senderId == null) {
|
if (event.eventId == null || event.senderId == null) {
|
||||||
return@forEach
|
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
|
// 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 (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
|
currentChunk.prevChunk = existingChunk
|
||||||
existingChunk.nextChunk = currentChunk
|
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
|
currentChunk.nextChunk = existingChunk
|
||||||
existingChunk.prevChunk = currentChunk
|
existingChunk.prevChunk = currentChunk
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Stop processing here
|
// Stop processing here
|
||||||
return@processTimelineEvents
|
return@processTimelineEvents
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue