fix: Event statuses progress and are saved correctly

This commit is contained in:
Sorunome 2020-08-14 16:09:20 +02:00
parent cbc66ea308
commit 20d72eb8d7
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
3 changed files with 19 additions and 7 deletions

View file

@ -424,6 +424,7 @@ class Database extends _$Database {
// is there a transaction id? Then delete the event with this id. // is there a transaction id? Then delete the event with this id.
if (status != -1 && if (status != -1 &&
status != 0 &&
eventUpdate.content['unsigned'] is Map && eventUpdate.content['unsigned'] is Map &&
eventUpdate.content['unsigned']['transaction_id'] is String) { eventUpdate.content['unsigned']['transaction_id'] is String) {
await removeEvent(clientId, await removeEvent(clientId,

View file

@ -211,7 +211,11 @@ class Timeline {
if (eventUpdate.roomID != room.id) return; if (eventUpdate.roomID != room.id) return;
if (eventUpdate.type == 'timeline' || eventUpdate.type == 'history') { if (eventUpdate.type == 'timeline' || eventUpdate.type == 'history') {
var status = eventUpdate.content['status'] ?? 2; var status = eventUpdate.content['status'] ??
(eventUpdate.content['unsigned'] is Map<String, dynamic>
? eventUpdate.content['unsigned'][MessageSendingStatusKey]
: null) ??
2;
// Redaction events are handled as modification for existing events. // Redaction events are handled as modification for existing events.
if (eventUpdate.eventType == EventTypes.Redaction) { if (eventUpdate.eventType == EventTypes.Redaction) {
final eventId = _findEvent(event_id: eventUpdate.content['redacts']); final eventId = _findEvent(event_id: eventUpdate.content['redacts']);

View file

@ -371,9 +371,12 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'content': {'msgtype': 'm.text', 'body': 'Testcase'}, 'content': {'msgtype': 'm.text', 'body': 'Testcase'},
'sender': '@alice:example.com', 'sender': '@alice:example.com',
'status': 0,
'event_id': 'transaction', 'event_id': 'transaction',
'origin_server_ts': testTimeStamp 'origin_server_ts': testTimeStamp,
'unsigned': {
MessageSendingStatusKey: 0,
'transaction_id': 'transaction',
},
}, },
sortOrder: room.newSortOrder)); sortOrder: room.newSortOrder));
await Future.delayed(Duration(milliseconds: 50)); await Future.delayed(Duration(milliseconds: 50));
@ -387,10 +390,12 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'content': {'msgtype': 'm.text', 'body': 'Testcase'}, 'content': {'msgtype': 'm.text', 'body': 'Testcase'},
'sender': '@alice:example.com', 'sender': '@alice:example.com',
'status': 2,
'event_id': '\$event', 'event_id': '\$event',
'origin_server_ts': testTimeStamp, 'origin_server_ts': testTimeStamp,
'unsigned': {'transaction_id': 'transaction'} 'unsigned': {
'transaction_id': 'transaction',
MessageSendingStatusKey: 2,
},
}, },
sortOrder: room.newSortOrder)); sortOrder: room.newSortOrder));
await Future.delayed(Duration(milliseconds: 50)); await Future.delayed(Duration(milliseconds: 50));
@ -404,10 +409,12 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'content': {'msgtype': 'm.text', 'body': 'Testcase'}, 'content': {'msgtype': 'm.text', 'body': 'Testcase'},
'sender': '@alice:example.com', 'sender': '@alice:example.com',
'status': 1,
'event_id': '\$event', 'event_id': '\$event',
'origin_server_ts': testTimeStamp, 'origin_server_ts': testTimeStamp,
'unsigned': {'transaction_id': 'transaction'} 'unsigned': {
'transaction_id': 'transaction',
MessageSendingStatusKey: 1,
},
}, },
sortOrder: room.newSortOrder)); sortOrder: room.newSortOrder));
await Future.delayed(Duration(milliseconds: 50)); await Future.delayed(Duration(milliseconds: 50));