From 500e423c0093d73d3fe53130cc2447cb99a930ee Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 14 Sep 2023 17:07:18 +0200 Subject: [PATCH] fix: storing the end of history pagination At least in our CI this throws a null assertion error and since we explicitly expect this to sometimes be null in our code, we should store it as such. --- lib/src/database/database_api.dart | 2 +- lib/src/database/hive_collections_database.dart | 2 +- lib/src/database/hive_database.dart | 2 +- lib/src/room.dart | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/database/database_api.dart b/lib/src/database/database_api.dart index 02059ce3..589e7102 100644 --- a/lib/src/database/database_api.dart +++ b/lib/src/database/database_api.dart @@ -233,7 +233,7 @@ abstract class DatabaseApi { Future removeEvent(String eventId, String roomId); Future setRoomPrevBatch( - String prevBatch, + String? prevBatch, String roomId, Client client, ); diff --git a/lib/src/database/hive_collections_database.dart b/lib/src/database/hive_collections_database.dart index 94a896e4..117ce23f 100644 --- a/lib/src/database/hive_collections_database.dart +++ b/lib/src/database/hive_collections_database.dart @@ -944,7 +944,7 @@ class HiveCollectionsDatabase extends DatabaseApi { @override Future setRoomPrevBatch( - String prevBatch, String roomId, Client client) async { + String? prevBatch, String roomId, Client client) async { final raw = await _roomsBox.get(roomId); if (raw == null) return; final room = Room.fromJson(copyMap(raw), client); diff --git a/lib/src/database/hive_database.dart b/lib/src/database/hive_database.dart index 114b4232..f3bfa9c7 100644 --- a/lib/src/database/hive_database.dart +++ b/lib/src/database/hive_database.dart @@ -885,7 +885,7 @@ class FamedlySdkHiveDatabase extends DatabaseApi { @override Future setRoomPrevBatch( - String prevBatch, String roomId, Client client) async { + String? prevBatch, String roomId, Client client) async { final raw = await _roomsBox.get(roomId.toHiveKey); if (raw == null) return; final room = Room.fromJson(convertToJson(raw), client); diff --git a/lib/src/room.dart b/lib/src/room.dart index 2596fcea..f4b3e6e8 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -1281,7 +1281,7 @@ class Room { if (client.database != null) { await client.database?.transaction(() async { if (storeInDatabase) { - await client.database?.setRoomPrevBatch(resp.end!, id, client); + await client.database?.setRoomPrevBatch(resp.end, id, client); } await loadFn(); });