fix: Fetching history sometimes re-sorting events in the timeline
This commit is contained in:
parent
66572bd032
commit
c509144987
|
|
@ -421,6 +421,8 @@ class Database extends _$Database {
|
||||||
if (roomUpdate.limitedTimeline) {
|
if (roomUpdate.limitedTimeline) {
|
||||||
await removeSuccessfulRoomEvents(clientId, roomUpdate.id);
|
await removeSuccessfulRoomEvents(clientId, roomUpdate.id);
|
||||||
await updateRoomSortOrder(0.0, 0.0, clientId, roomUpdate.id);
|
await updateRoomSortOrder(0.0, 0.0, clientId, roomUpdate.id);
|
||||||
|
}
|
||||||
|
if (roomUpdate.prev_batch != null) {
|
||||||
await setRoomPrevBatch(roomUpdate.prev_batch, clientId, roomUpdate.id);
|
await setRoomPrevBatch(roomUpdate.prev_batch, clientId, roomUpdate.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -287,8 +287,12 @@ class Timeline {
|
||||||
if (i < events.length) {
|
if (i < events.length) {
|
||||||
// if the old status is larger than the new one, we also want to preserve the old status
|
// if the old status is larger than the new one, we also want to preserve the old status
|
||||||
final oldStatus = events[i].status;
|
final oldStatus = events[i].status;
|
||||||
events[i] =
|
events[i] = Event.fromJson(
|
||||||
Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder);
|
eventUpdate.content,
|
||||||
|
room,
|
||||||
|
eventUpdate.type == EventUpdateType.history
|
||||||
|
? events[i].sortOrder
|
||||||
|
: eventUpdate.sortOrder);
|
||||||
// do we preserve the status? we should allow 0 -> -1 updates and status increases
|
// do we preserve the status? we should allow 0 -> -1 updates and status increases
|
||||||
if (status < oldStatus && !(status == -1 && oldStatus == 0)) {
|
if (status < oldStatus && !(status == -1 && oldStatus == 0)) {
|
||||||
events[i].status = oldStatus;
|
events[i].status = oldStatus;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue