fix: archived room state store logic

This was implicitly relying to the timestamp of state events getting
compared in the setState function. Fix this by using the helper
functions already used for invite and join rooms.
This commit is contained in:
Nicolas Werner 2024-03-04 19:31:35 +01:00
parent 69fe7845a9
commit f6fa9df2c5
No known key found for this signature in database
GPG Key ID: B38119FF80087618
1 changed files with 12 additions and 12 deletions

View File

@ -1071,19 +1071,19 @@ class Client extends MatrixApi {
[]));
archivedRoom.prev_batch = update.timeline?.prevBatch;
update.state?.forEach((event) {
archivedRoom.setState(Event.fromMatrixEvent(
event,
archivedRoom,
));
});
update.timeline?.events?.forEach((event) {
archivedRoom.setState(Event.fromMatrixEvent(
event,
archivedRoom,
));
});
final stateEvents = roomUpdate.state;
if (stateEvents != null) {
await _handleRoomEvents(archivedRoom, stateEvents, EventUpdateType.state,
store: false);
}
final timelineEvents = roomUpdate.timeline?.events;
if (timelineEvents != null) {
await _handleRoomEvents(archivedRoom, timelineEvents.reversed.toList(),
EventUpdateType.timeline,
store: false);
}
for (var i = 0; i < timeline.events.length; i++) {
// Try to decrypt encrypted events but don't update the database.