From f052957c0adeeda2f84d6b865d218c18a8f10d8c Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Thu, 11 Nov 2021 09:48:50 +0100 Subject: [PATCH] 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. --- lib/src/room.dart | 3 ++- test/room_test.dart | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index b8271112..43c98a16 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -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; } diff --git a/test/room_test.dart b/test/room_test.dart index b68f08de..651aa83f 100644 --- a/test/room_test.dart +++ b/test/room_test.dart @@ -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(