From 00d03e93301d45ef0f7e3dc8a53069b7a8700032 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 8 Jan 2021 12:24:27 +0100 Subject: [PATCH] fix: Sort at the end --- lib/src/client.dart | 4 +++- lib/src/timeline.dart | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index 728461a6..0fb21f43 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1287,7 +1287,9 @@ class Client extends MatrixApi { var stateEvent = Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder); 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(''' 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 diff --git a/lib/src/timeline.dart b/lib/src/timeline.dart index 6141d392..f58677c3 100644 --- a/lib/src/timeline.dart +++ b/lib/src/timeline.dart @@ -43,7 +43,7 @@ class Timeline { StreamSubscription sub; StreamSubscription roomSub; StreamSubscription sessionIdReceivedSub; - bool _requestingHistoryLock = false; + bool isRequestingHistory = false; final Map _eventCache = {}; @@ -70,8 +70,8 @@ class Timeline { Future requestHistory( {int historyCount = Room.DefaultHistoryCount}) async { - if (!_requestingHistoryLock) { - _requestingHistoryLock = true; + if (!isRequestingHistory) { + isRequestingHistory = true; await room.requestHistory( historyCount: historyCount, onHistoryReceived: () { @@ -83,7 +83,7 @@ class Timeline { _proccessHistoryUpdates(); } finally { _collectHistoryUpdates = false; - _requestingHistoryLock = false; + isRequestingHistory = false; } } }