[Room] Store prevBatch when requesting history

This commit is contained in:
Christian 2019-06-28 10:32:33 +00:00 committed by Marcel
parent a05068d156
commit b8de0f054b
3 changed files with 10 additions and 0 deletions

View File

@ -300,6 +300,9 @@ class Room {
if (resp is ErrorResponse) return;
prev_batch = resp["end"];
client.store?.storeRoomPrevBatch(this);
if (!(resp["chunk"] is List<dynamic> &&
resp["chunk"].length > 0 &&
resp["end"] is String)) return;

View File

@ -149,6 +149,12 @@ class Store {
return null;
}
Future<void> storeRoomPrevBatch(Room room) async {
await _db.rawUpdate(
"UPDATE Rooms SET prev_batch=? WHERE id=?", [room.prev_batch, room.id]);
return null;
}
/// Stores a RoomUpdate object in the database. Must be called inside of
/// [transaction].
Future<void> storeRoomUpdate(RoomUpdate roomUpdate) {

View File

@ -198,6 +198,7 @@ void main() {
expect(timeline.events[6].id, "1143273582443PhrSn:example.org");
expect(timeline.events[7].id, "2143273582443PhrSn:example.org");
expect(timeline.events[8].id, "3143273582443PhrSn:example.org");
expect(room.prev_batch, "t47409-4357353_219380_26003_2265");
});
});
}