fix: Change eventstatus of edits in prevEvent

Unfortunately the last fix
was not working.
This fixes it for real now and also
adds a test case to make sure it
never breaks again.
This commit is contained in:
Krille Fear 2021-11-11 09:48:50 +01:00
parent 5f448020af
commit f052957c0a
2 changed files with 28 additions and 1 deletions

View File

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

View File

@ -234,9 +234,35 @@ void main() {
'm.relates_to': {'rel_type': 'm.replace', 'event_id': '2'},
},
stateKey: '',
status: EventStatus.sending,
),
);
expect(room.lastEvent?.body, 'edited cdc');
expect(room.lastEvent?.status, EventStatus.sending);
expect(room.lastEvent?.eventId, '4');
// Status update on edits working?
room.setState(
Event(
senderId: '@test:example.com',
type: 'm.room.encrypted',
room: room,
eventId: '5',
unsigned: {'transaction_id': '4'},
originServerTs: DateTime.now(),
content: {
'msgtype': 'm.text',
'body': 'edited cdc',
'm.new_content': {'msgtype': 'm.text', 'body': 'edited cdc'},
'm.relates_to': {'rel_type': 'm.replace', 'event_id': '2'},
},
stateKey: '',
status: EventStatus.sent,
),
);
expect(room.lastEvent?.eventId, '5');
expect(room.lastEvent?.body, 'edited cdc');
expect(room.lastEvent?.status, EventStatus.sent);
});
test('lastEvent when reply parent edited', () async {
room.setState(