Merge branch 'room-fix-save-prevbatch' into 'master'
[Room] Store prevBatch when requesting history See merge request famedly/famedlysdk!26
This commit is contained in:
commit
432cf5fc98
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue