refactor: Use handleRoomEvents method instead of handleEvent
This makes it easier to update the state by a whole timeline.
This commit is contained in:
parent
fc229c5715
commit
c591c1d4b5
|
|
@ -1749,7 +1749,7 @@ class Client extends MatrixApi {
|
|||
|
||||
Future<void> _handleEphemerals(Room room, List<BasicRoomEvent> events) async {
|
||||
for (final event in events) {
|
||||
await _handleEvent(event, room, EventUpdateType.ephemeral);
|
||||
await _handleRoomEvents(room, [event], EventUpdateType.ephemeral);
|
||||
|
||||
// Receipt events are deltas between two states. We will create a
|
||||
// fake room account data event for this and store the difference
|
||||
|
|
@ -1783,7 +1783,7 @@ class Client extends MatrixApi {
|
|||
}
|
||||
}
|
||||
event.content = receiptStateContent;
|
||||
await _handleEvent(event, room, EventUpdateType.accountData);
|
||||
await _handleRoomEvents(room, [event], EventUpdateType.accountData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1794,15 +1794,6 @@ class Client extends MatrixApi {
|
|||
EventUpdateType type,
|
||||
) async {
|
||||
for (final event in events) {
|
||||
await _handleEvent(event, room, type);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleEvent(
|
||||
BasicEvent event,
|
||||
Room room,
|
||||
EventUpdateType type,
|
||||
) async {
|
||||
// The client must ignore any new m.room.encryption event to prevent
|
||||
// man-in-the-middle attacks!
|
||||
if ((event.type == EventTypes.Encryption &&
|
||||
|
|
@ -1875,6 +1866,7 @@ class Client extends MatrixApi {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Room _updateRoomsByRoomUpdate(String roomId, SyncRoomUpdate chatUpdate) {
|
||||
// Update the chat list item.
|
||||
|
|
|
|||
Loading…
Reference in New Issue