From e11878eef6b78b9609b57d7d3fb1ff4ec7d6f7da Mon Sep 17 00:00:00 2001 From: Karthikeyan S Date: Tue, 11 Mar 2025 17:32:43 +0530 Subject: [PATCH] fix: room prev_batch set incorrectly --- lib/src/room.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index d41c42e3..77338324 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -1322,7 +1322,7 @@ class Room { ); if (onHistoryReceived != null) onHistoryReceived(); - this.prev_batch = resp.end; + final newPrevBatch = direction == Direction.b ? resp.end : resp.start; Future loadFn() async { if (!((resp.chunk.isNotEmpty) && resp.end != null)) return; @@ -1340,8 +1340,7 @@ class Room { events: direction == Direction.b ? resp.chunk : resp.chunk.reversed.toList(), - prevBatch: - direction == Direction.b ? resp.end : resp.start, + prevBatch: newPrevBatch, ), ), } @@ -1355,8 +1354,7 @@ class Room { events: direction == Direction.b ? resp.chunk : resp.chunk.reversed.toList(), - prevBatch: - direction == Direction.b ? resp.end : resp.start, + prevBatch: newPrevBatch, ), ), } @@ -1370,7 +1368,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(newPrevBatch, id, client); } await loadFn(); });