fix: Set new state events by sortOrder, rather than originServerTs
This commit is contained in:
parent
c509144987
commit
588d7eb1a6
|
|
@ -145,11 +145,8 @@ class Room {
|
|||
.contains(state.type)) {
|
||||
return;
|
||||
}
|
||||
if ((getState(state.type, state.stateKey ?? '')
|
||||
?.originServerTs
|
||||
?.millisecondsSinceEpoch ??
|
||||
0) >
|
||||
(state.originServerTs?.millisecondsSinceEpoch ?? 1)) {
|
||||
final oldStateEvent = getState(state.type, state.stateKey ?? '');
|
||||
if (oldStateEvent != null && oldStateEvent.sortOrder >= state.sortOrder) {
|
||||
return;
|
||||
}
|
||||
if (!states.states.containsKey(state.type)) {
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ void main() {
|
|||
'state_key': '',
|
||||
'type': 'm.room.join_rules',
|
||||
'unsigned': {'age': 1234}
|
||||
}, room));
|
||||
}, room, 1432735824653.0));
|
||||
expect(room.joinRules, JoinRules.invite);
|
||||
await room.setJoinRules(JoinRules.invite);
|
||||
});
|
||||
|
|
@ -581,7 +581,7 @@ void main() {
|
|||
'state_key': '',
|
||||
'type': 'm.room.guest_access',
|
||||
'unsigned': {'age': 1234}
|
||||
}, room));
|
||||
}, room, 1432735824653.0));
|
||||
expect(room.guestAccess, GuestAccess.can_join);
|
||||
await room.setGuestAccess(GuestAccess.can_join);
|
||||
});
|
||||
|
|
@ -598,7 +598,7 @@ void main() {
|
|||
'state_key': '',
|
||||
'type': 'm.room.history_visibility',
|
||||
'unsigned': {'age': 1234}
|
||||
}, room));
|
||||
}, room, 1432735824653.0));
|
||||
expect(room.historyVisibility, HistoryVisibility.shared);
|
||||
await room.setHistoryVisibility(HistoryVisibility.joined);
|
||||
});
|
||||
|
|
@ -613,7 +613,7 @@ void main() {
|
|||
'sender': '@example:example.org',
|
||||
'type': 'm.custom',
|
||||
'unsigned': {'age': 1234}
|
||||
}, room));
|
||||
}, room, 1432735824653.0));
|
||||
expect(room.getState('m.custom') != null, false);
|
||||
|
||||
// set state events
|
||||
|
|
@ -626,7 +626,7 @@ void main() {
|
|||
'state_key': '',
|
||||
'type': 'm.custom',
|
||||
'unsigned': {'age': 1234}
|
||||
}, room));
|
||||
}, room, 1432735824653.0));
|
||||
expect(room.getState('m.custom') != null, true);
|
||||
|
||||
// sets messages as state events
|
||||
|
|
@ -638,7 +638,7 @@ void main() {
|
|||
'sender': '@example:example.org',
|
||||
'type': 'm.room.message',
|
||||
'unsigned': {'age': 1234}
|
||||
}, room));
|
||||
}, room, 1432735824653.0));
|
||||
expect(room.getState('m.room.message') != null, true);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue