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)) {
|
.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)) {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue