diff --git a/lib/src/event.dart b/lib/src/event.dart index 2ccc8e1..6305a1c 100644 --- a/lib/src/event.dart +++ b/lib/src/event.dart @@ -319,11 +319,11 @@ class Event extends MatrixEvent { if (status != -1) return null; // we do not remove the event here. It will automatically be updated // in the `sendEvent` method to transition -1 -> 0 -> 1 -> 2 - final eventID = await room.sendEvent( + final newEventId = await room.sendEvent( content, - txid: txid ?? unsigned['transaction_id'], + txid: txid ?? unsigned['transaction_id'] ?? eventId, ); - return eventID; + return newEventId; } /// Whether the client is allowed to redact this event. diff --git a/lib/src/room.dart b/lib/src/room.dart index 234ad39..8ba80b8 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -691,7 +691,10 @@ class Room { ..eventId = messageID ..senderId = client.userID ..originServerTs = DateTime.now() - ..unsigned = {MessageSendingStatusKey: 0}, + ..unsigned = { + MessageSendingStatusKey: 0, + 'transaction_id': messageID, + }, ])))); await client.handleSync(syncUpdate); @@ -709,8 +712,6 @@ class Room { ); syncUpdate.rooms.join.values.first.timeline.events.first .unsigned[MessageSendingStatusKey] = 1; - syncUpdate.rooms.join.values.first.timeline.events.first - .unsigned['transaction_id'] = messageID; syncUpdate.rooms.join.values.first.timeline.events.first.eventId = res; await client.handleSync(syncUpdate); return res;