fix: Also update last event on redaction in store
This commit is contained in:
parent
ac0fdc1deb
commit
8f38006c18
|
|
@ -990,7 +990,8 @@ class HiveCollectionsDatabase extends DatabaseApi {
|
|||
Future<void> storeEventUpdate(EventUpdate eventUpdate, Client client) async {
|
||||
// Ephemerals should not be stored
|
||||
if (eventUpdate.type == EventUpdateType.ephemeral) return;
|
||||
final tmpRoom = Room(id: eventUpdate.roomID, client: client);
|
||||
final tmpRoom = client.getRoomById(eventUpdate.roomID) ??
|
||||
Room(id: eventUpdate.roomID, client: client);
|
||||
|
||||
// In case of this is a redaction event
|
||||
if (eventUpdate.content['type'] == EventTypes.Redaction) {
|
||||
|
|
@ -1002,6 +1003,13 @@ class HiveCollectionsDatabase extends DatabaseApi {
|
|||
await _eventsBox.put(
|
||||
TupleKey(eventUpdate.roomID, event.eventId).toString(),
|
||||
event.toJson());
|
||||
|
||||
if (tmpRoom.lastEvent?.eventId == event.eventId) {
|
||||
await _roomStateBox.put(
|
||||
TupleKey(eventUpdate.roomID, event.type).toString(),
|
||||
{'': event.toJson()},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -935,7 +935,8 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
|||
|
||||
// In case of this is a redaction event
|
||||
if (eventUpdate.content['type'] == EventTypes.Redaction) {
|
||||
final tmpRoom = Room(id: eventUpdate.roomID, client: client);
|
||||
final tmpRoom = client.getRoomById(eventUpdate.roomID) ??
|
||||
Room(id: eventUpdate.roomID, client: client);
|
||||
final eventId = eventUpdate.content.tryGet<String>('redacts');
|
||||
final event =
|
||||
eventId != null ? await getEventById(eventId, tmpRoom) : null;
|
||||
|
|
@ -944,6 +945,13 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
|||
await _eventsBox.put(
|
||||
MultiKey(eventUpdate.roomID, event.eventId).toString(),
|
||||
event.toJson());
|
||||
|
||||
if (tmpRoom.lastEvent?.eventId == event.eventId) {
|
||||
await _roomStateBox.put(
|
||||
MultiKey(eventUpdate.roomID, event.type).toString(),
|
||||
{'': event.toJson()},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue