[Event] Fix wrong id reference
This commit is contained in:
parent
8f96088f09
commit
93d904b1ae
|
@ -137,7 +137,7 @@ class Event {
|
|||
}
|
||||
|
||||
return Event(
|
||||
jsonObj["id"],
|
||||
jsonObj["event_id"],
|
||||
User.fromJson(jsonObj, room),
|
||||
ChatTime(jsonObj["origin_server_ts"]),
|
||||
stateKey: User(jsonObj["state_key"]),
|
||||
|
|
|
@ -184,7 +184,7 @@ class Room {
|
|||
EventUpdate eventUpdate =
|
||||
EventUpdate(type: "timeline", roomID: id, eventType: type, content: {
|
||||
"type": type,
|
||||
"id": messageID,
|
||||
"event_id": messageID,
|
||||
"sender": client.userID,
|
||||
"status": 0,
|
||||
"origin_server_ts": now,
|
||||
|
@ -202,7 +202,7 @@ class Room {
|
|||
// Send the text and on success, store and display a *sent* event.
|
||||
final dynamic res = await sendText(message, txid: messageID);
|
||||
|
||||
if (res is ErrorResponse) {
|
||||
if (res is ErrorResponse || !(res["event_id"] is String)) {
|
||||
// On error, set status to -1
|
||||
eventUpdate.content["status"] = -1;
|
||||
client.connection.onEvent.add(eventUpdate);
|
||||
|
@ -210,14 +210,13 @@ class Room {
|
|||
client.store.storeEventUpdate(eventUpdate);
|
||||
});
|
||||
} else {
|
||||
final String newEventID = res["event_id"];
|
||||
eventUpdate.content["status"] = 1;
|
||||
eventUpdate.content["id"] = newEventID;
|
||||
eventUpdate.content["event_id"] = res["event_id"];
|
||||
client.connection.onEvent.add(eventUpdate);
|
||||
await client.store?.transaction(() {
|
||||
client.store.storeEventUpdate(eventUpdate);
|
||||
});
|
||||
return newEventID;
|
||||
return res["event_id"];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class Timeline {
|
|||
if (events[i].content.containsKey("txid") &&
|
||||
events[i].content["txid"] ==
|
||||
eventUpdate.content["content"]["txid"] ||
|
||||
events[i].id == eventUpdate.content["id"] ||
|
||||
events[i].id == eventUpdate.content["event_id"] ||
|
||||
(eventUpdate.content.containsKey("unsigned") &&
|
||||
eventUpdate.content["unsigned"]["transaction_id"]
|
||||
is String &&
|
||||
|
@ -69,9 +69,6 @@ class Timeline {
|
|||
events[i] = Event.fromJson(eventUpdate.content, room);
|
||||
}
|
||||
} else {
|
||||
if (!eventUpdate.content.containsKey("id"))
|
||||
eventUpdate.content["id"] = eventUpdate.content["event_id"];
|
||||
|
||||
User user = await room.client.store
|
||||
?.getUser(matrixID: eventUpdate.content["sender"], room: room);
|
||||
if (user != null) {
|
||||
|
|
|
@ -62,7 +62,7 @@ void main() {
|
|||
"content": {"msgtype": "m.text", "body": "Testcase"},
|
||||
"sender": "@alice:example.com",
|
||||
"status": 2,
|
||||
"id": "1",
|
||||
"event_id": "1",
|
||||
"origin_server_ts": testTimeStamp
|
||||
}));
|
||||
|
||||
|
@ -75,7 +75,7 @@ void main() {
|
|||
"content": {"msgtype": "m.text", "body": "Testcase"},
|
||||
"sender": "@alice:example.com",
|
||||
"status": 2,
|
||||
"id": "2",
|
||||
"event_id": "2",
|
||||
"origin_server_ts": testTimeStamp - 1000
|
||||
}));
|
||||
|
||||
|
@ -116,7 +116,7 @@ void main() {
|
|||
"content": {"msgtype": "m.text", "body": "test"},
|
||||
"sender": "@alice:example.com",
|
||||
"status": 2,
|
||||
"id": "42",
|
||||
"event_id": "42",
|
||||
"unsigned": {"transaction_id": "1234"},
|
||||
"origin_server_ts": DateTime.now().millisecondsSinceEpoch
|
||||
}));
|
||||
|
@ -140,7 +140,7 @@ void main() {
|
|||
"content": {"msgtype": "m.text", "body": "Testcase"},
|
||||
"sender": "@alice:example.com",
|
||||
"status": 0,
|
||||
"id": "abc",
|
||||
"event_id": "abc",
|
||||
"origin_server_ts": testTimeStamp
|
||||
}));
|
||||
await new Future.delayed(new Duration(milliseconds: 50));
|
||||
|
|
Loading…
Reference in a new issue