fix: Set new state events by sortOrder, rather than originServerTs

This commit is contained in:
Sorunome 2020-11-08 15:03:23 +01:00
parent c509144987
commit 588d7eb1a6
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 8 additions and 11 deletions

View File

@ -145,11 +145,8 @@ class Room {
.contains(state.type)) { .contains(state.type)) {
return; return;
} }
if ((getState(state.type, state.stateKey ?? '') final oldStateEvent = getState(state.type, state.stateKey ?? '');
?.originServerTs if (oldStateEvent != null && oldStateEvent.sortOrder >= state.sortOrder) {
?.millisecondsSinceEpoch ??
0) >
(state.originServerTs?.millisecondsSinceEpoch ?? 1)) {
return; return;
} }
if (!states.states.containsKey(state.type)) { if (!states.states.containsKey(state.type)) {

View File

@ -564,7 +564,7 @@ void main() {
'state_key': '', 'state_key': '',
'type': 'm.room.join_rules', 'type': 'm.room.join_rules',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room)); }, room, 1432735824653.0));
expect(room.joinRules, JoinRules.invite); expect(room.joinRules, JoinRules.invite);
await room.setJoinRules(JoinRules.invite); await room.setJoinRules(JoinRules.invite);
}); });
@ -581,7 +581,7 @@ void main() {
'state_key': '', 'state_key': '',
'type': 'm.room.guest_access', 'type': 'm.room.guest_access',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room)); }, room, 1432735824653.0));
expect(room.guestAccess, GuestAccess.can_join); expect(room.guestAccess, GuestAccess.can_join);
await room.setGuestAccess(GuestAccess.can_join); await room.setGuestAccess(GuestAccess.can_join);
}); });
@ -598,7 +598,7 @@ void main() {
'state_key': '', 'state_key': '',
'type': 'm.room.history_visibility', 'type': 'm.room.history_visibility',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room)); }, room, 1432735824653.0));
expect(room.historyVisibility, HistoryVisibility.shared); expect(room.historyVisibility, HistoryVisibility.shared);
await room.setHistoryVisibility(HistoryVisibility.joined); await room.setHistoryVisibility(HistoryVisibility.joined);
}); });
@ -613,7 +613,7 @@ void main() {
'sender': '@example:example.org', 'sender': '@example:example.org',
'type': 'm.custom', 'type': 'm.custom',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room)); }, room, 1432735824653.0));
expect(room.getState('m.custom') != null, false); expect(room.getState('m.custom') != null, false);
// set state events // set state events
@ -626,7 +626,7 @@ void main() {
'state_key': '', 'state_key': '',
'type': 'm.custom', 'type': 'm.custom',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room)); }, room, 1432735824653.0));
expect(room.getState('m.custom') != null, true); expect(room.getState('m.custom') != null, true);
// sets messages as state events // sets messages as state events
@ -638,7 +638,7 @@ void main() {
'sender': '@example:example.org', 'sender': '@example:example.org',
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room)); }, room, 1432735824653.0));
expect(room.getState('m.room.message') != null, true); expect(room.getState('m.room.message') != null, true);
}); });