Merge pull request #1998 from famedly/karthi/transactionId
chore: add transactionId getter to Event class
This commit is contained in:
commit
8d7b4dd9c0
|
|
@ -1155,8 +1155,7 @@ class MatrixSdkDatabase extends DatabaseApi with DatabaseFileStorage {
|
|||
|
||||
final eventId = timelineEvent.eventId;
|
||||
// In case this event has sent from this account we have a transaction ID
|
||||
final transactionId =
|
||||
timelineEvent.unsigned?.tryGet<String>('transaction_id');
|
||||
final transactionId = timelineEvent.transactionId;
|
||||
await _eventsBox.put(
|
||||
TupleKey(roomId, eventId).toString(),
|
||||
timelineEvent.toJson(),
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ class Event extends MatrixEvent {
|
|||
|
||||
MatrixEvent? get originalSource => _originalSource;
|
||||
|
||||
String? get transactionId => unsigned?.tryGet<String>('transaction_id');
|
||||
|
||||
Event({
|
||||
this.status = defaultStatus,
|
||||
required Map<String, dynamic> super.content,
|
||||
|
|
@ -439,10 +441,9 @@ class Event extends MatrixEvent {
|
|||
final inReplyTo = credentials.inReplyTo == null
|
||||
? null
|
||||
: await room.getEventById(credentials.inReplyTo!);
|
||||
txid ??= unsigned?.tryGet<String>('transaction_id');
|
||||
return await room.sendFileEvent(
|
||||
file,
|
||||
txid: txid,
|
||||
txid: txid ?? transactionId,
|
||||
thumbnail: thumbnail,
|
||||
inReplyTo: inReplyTo,
|
||||
editEventId: credentials.editEventId,
|
||||
|
|
@ -455,7 +456,7 @@ class Event extends MatrixEvent {
|
|||
// in the `sendEvent` method to transition -1 -> 0 -> 1 -> 2
|
||||
return await room.sendEvent(
|
||||
content,
|
||||
txid: txid ?? unsigned?.tryGet<String>('transaction_id') ?? eventId,
|
||||
txid: txid ?? transactionId ?? eventId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -967,7 +968,7 @@ class Event extends MatrixEvent {
|
|||
if (eventId == search) {
|
||||
return true;
|
||||
}
|
||||
return unsigned?['transaction_id'] == search;
|
||||
return transactionId == search;
|
||||
}
|
||||
|
||||
/// Get the relationship type of an event. `null` if there is none
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ class Timeline {
|
|||
for (i = 0; i < events.length; i++) {
|
||||
final searchHaystack = <String>{events[i].eventId};
|
||||
|
||||
final txnid = events[i].unsigned?.tryGet<String>('transaction_id');
|
||||
final txnid = events[i].transactionId;
|
||||
if (txnid != null) {
|
||||
searchHaystack.add(txnid);
|
||||
}
|
||||
|
|
@ -489,9 +489,7 @@ class Timeline {
|
|||
(e) =>
|
||||
e.matchesEventOrTransactionId(event.eventId) ||
|
||||
event.unsigned != null &&
|
||||
e.matchesEventOrTransactionId(
|
||||
event.unsigned?.tryGet<String>('transaction_id'),
|
||||
),
|
||||
e.matchesEventOrTransactionId(event.transactionId),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -516,8 +514,8 @@ class Timeline {
|
|||
|
||||
void removeAggregatedEvent(Event event) {
|
||||
aggregatedEvents.remove(event.eventId);
|
||||
if (event.unsigned != null) {
|
||||
aggregatedEvents.remove(event.unsigned?['transaction_id']);
|
||||
if (event.transactionId != null) {
|
||||
aggregatedEvents.remove(event.transactionId);
|
||||
}
|
||||
for (final types in aggregatedEvents.values) {
|
||||
for (final events in types.values) {
|
||||
|
|
@ -548,7 +546,7 @@ class Timeline {
|
|||
|
||||
final i = _findEvent(
|
||||
event_id: event.eventId,
|
||||
unsigned_txid: event.unsigned?.tryGet<String>('transaction_id'),
|
||||
unsigned_txid: event.transactionId,
|
||||
);
|
||||
|
||||
if (i < events.length) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue