Merge branch 'krille/fix-sort-at-the-end' into 'main'

fix: Sort at the end

Closes app#1037

See merge request famedly/famedlysdk!607
This commit is contained in:
Sorunome 2021-01-12 12:22:21 +00:00
commit ef854b3b4c
2 changed files with 7 additions and 5 deletions

View File

@ -1306,7 +1306,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;
} }
} }
} }