fix: Allow consecutive edits for state events in-memory

The lastEvent was incorrect when trying to process an edit of an edit.
This fixes that by allowing consecutive edits for the last event.
This commit is contained in:
Sorunome 2021-12-06 11:10:24 +01:00
parent e3bd0cf139
commit b009ada0ac
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 37 additions and 1 deletions

View File

@ -188,7 +188,9 @@ class Room {
state.relationshipType == RelationshipTypes.edit && state.relationshipType == RelationshipTypes.edit &&
lastEvent != null && lastEvent != null &&
!state.matchesEventOrTransactionId(lastEvent.eventId) && !state.matchesEventOrTransactionId(lastEvent.eventId) &&
lastEvent.eventId != state.relationshipEventId) { lastEvent.eventId != state.relationshipEventId &&
!(lastEvent.relationshipType == RelationshipTypes.edit &&
lastEvent.relationshipEventId == state.relationshipEventId)) {
return; return;
} }

View File

@ -492,6 +492,40 @@ void main() {
} }
})); }));
expect(room.getState('m.room.message')!.content['body'], '* floooof'); expect(room.getState('m.room.message')!.content['body'], '* floooof');
// accepts a consecutive edit
await matrix.handleSync(SyncUpdate.fromJson({
'next_batch': 'fakesync',
'rooms': {
'join': {
roomId: {
'timeline': {
'events': [
<String, dynamic>{
'sender': '@alice:example.com',
'type': 'm.room.message',
'content': <String, dynamic>{
'msgtype': 'm.text',
'body': '* foxies',
'm.new_content': <String, dynamic>{
'msgtype': 'm.text',
'body': 'foxies',
},
'm.relates_to': <String, dynamic>{
'rel_type': 'm.replace',
'event_id': '\$last:example.com'
},
},
'origin_server_ts': 1417731086799,
'event_id': '\$edit2:example.com'
}
]
}
}
}
}
}));
expect(room.getState('m.room.message')!.content['body'], '* foxies');
}); });
test('getProfileFromUserId', () async { test('getProfileFromUserId', () async {