diff --git a/lib/src/Event.dart b/lib/src/Event.dart
index eba53c8..8f0feb9 100644
--- a/lib/src/Event.dart
+++ b/lib/src/Event.dart
@@ -21,6 +21,7 @@
* along with famedlysdk. If not, see .
*/
+import 'package:famedlysdk/src/State.dart';
import 'package:famedlysdk/src/sync/EventUpdate.dart';
import 'package:famedlysdk/src/utils/ChatTime.dart';
@@ -28,7 +29,7 @@ import './Room.dart';
import './RawEvent.dart';
/// Defines a timeline event for a room.
-class Event extends RawEvent {
+class Event extends State {
/// The status of this event.
/// -1=ERROR
/// 0=SENDING
@@ -45,6 +46,8 @@ class Event extends RawEvent {
String senderId,
ChatTime time,
dynamic unsigned,
+ dynamic prevContent,
+ String stateKey,
Room room})
: super(
content: content,
@@ -54,6 +57,8 @@ class Event extends RawEvent {
senderId: senderId,
time: time,
unsigned: unsigned,
+ prevContent: prevContent,
+ stateKey: stateKey,
room: room);
/// Get a State event from a table row or from the event stream.
@@ -62,6 +67,8 @@ class Event extends RawEvent {
RawEvent.getMapFromPayload(jsonPayload['content']);
final Map unsigned =
RawEvent.getMapFromPayload(jsonPayload['unsigned']);
+ final Map prevContent =
+ RawEvent.getMapFromPayload(jsonPayload['prev_content']);
return Event(
status: jsonPayload['status'] ?? 1,
content: content,
@@ -71,6 +78,8 @@ class Event extends RawEvent {
senderId: jsonPayload['sender'],
time: ChatTime(jsonPayload['origin_server_ts']),
unsigned: unsigned,
+ prevContent: prevContent,
+ stateKey: jsonPayload['state_key'],
room: room);
}
diff --git a/lib/src/Store.dart b/lib/src/Store.dart
index 870e0f0..592bafa 100644
--- a/lib/src/Store.dart
+++ b/lib/src/Store.dart
@@ -250,16 +250,19 @@ class Store {
]);
else
txn.rawInsert(
- "INSERT OR REPLACE INTO Events VALUES(?, ?, ?, ?, ?, ?, ?, ?)", [
- eventContent["event_id"],
- chat_id,
- eventContent["origin_server_ts"],
- eventContent["sender"],
- eventContent["type"],
- json.encode(eventContent["unsigned"] ?? ""),
- json.encode(eventContent["content"]),
- status
- ]);
+ "INSERT OR REPLACE INTO Events VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ [
+ eventContent["event_id"],
+ chat_id,
+ eventContent["origin_server_ts"],
+ eventContent["sender"],
+ eventContent["type"],
+ json.encode(eventContent["unsigned"] ?? ""),
+ json.encode(eventContent["content"]),
+ json.encode(eventContent["prevContent"]),
+ eventContent["state_key"],
+ status
+ ]);
// Is there a transaction id? Then delete the event with this id.
if (status != -1 &&
@@ -474,6 +477,8 @@ class Store {
'type TEXT, ' +
'unsigned TEXT, ' +
'content TEXT, ' +
+ 'prev_content TEXT, ' +
+ 'state_key TEXT, ' +
"status INTEGER, " +
'UNIQUE(id))',