fix: Sort at the end

This commit is contained in:
Christian Pauly 2021-01-08 12:24:27 +01:00
parent 734431d553
commit 00d03e9330
2 changed files with 7 additions and 5 deletions

View File

@ -1287,7 +1287,9 @@ class Client extends MatrixApi {
var stateEvent = var stateEvent =
Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder); Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder);
var prevState = room.getState(stateEvent.type, stateEvent.stateKey); var prevState = room.getState(stateEvent.type, stateEvent.stateKey);
if (prevState != null && prevState.sortOrder > stateEvent.sortOrder) { if (eventUpdate.type == EventUpdateType.timeline &&
prevState != null &&
prevState.sortOrder > stateEvent.sortOrder) {
Logs().w(''' Logs().w('''
A new ${eventUpdate.type} event of the type ${stateEvent.type} has arrived with a previews A new ${eventUpdate.type} event of the type ${stateEvent.type} has arrived with a previews
sort order ${stateEvent.sortOrder} than the current ${stateEvent.type} event with a sort order ${stateEvent.sortOrder} than the current ${stateEvent.type} event with a

View File

@ -43,7 +43,7 @@ class Timeline {
StreamSubscription<EventUpdate> sub; StreamSubscription<EventUpdate> sub;
StreamSubscription<RoomUpdate> roomSub; StreamSubscription<RoomUpdate> roomSub;
StreamSubscription<String> sessionIdReceivedSub; StreamSubscription<String> sessionIdReceivedSub;
bool _requestingHistoryLock = false; bool isRequestingHistory = false;
final Map<String, Event> _eventCache = {}; final Map<String, Event> _eventCache = {};
@ -70,8 +70,8 @@ class Timeline {
Future<void> requestHistory( Future<void> requestHistory(
{int historyCount = Room.DefaultHistoryCount}) async { {int historyCount = Room.DefaultHistoryCount}) async {
if (!_requestingHistoryLock) { if (!isRequestingHistory) {
_requestingHistoryLock = true; isRequestingHistory = true;
await room.requestHistory( await room.requestHistory(
historyCount: historyCount, historyCount: historyCount,
onHistoryReceived: () { onHistoryReceived: () {
@ -83,7 +83,7 @@ class Timeline {
_proccessHistoryUpdates(); _proccessHistoryUpdates();
} finally { } finally {
_collectHistoryUpdates = false; _collectHistoryUpdates = false;
_requestingHistoryLock = false; isRequestingHistory = false;
} }
} }
} }