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 =
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

View File

@ -43,7 +43,7 @@ class Timeline {
StreamSubscription<EventUpdate> sub;
StreamSubscription<RoomUpdate> roomSub;
StreamSubscription<String> sessionIdReceivedSub;
bool _requestingHistoryLock = false;
bool isRequestingHistory = false;
final Map<String, Event> _eventCache = {};
@ -70,8 +70,8 @@ class Timeline {
Future<void> 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;
}
}
}