fix: room prev_batch set incorrectly follow-up

This commit is contained in:
Karthikeyan S 2025-03-13 10:05:05 +05:30
parent a75e0b9af4
commit 0d084d8824
No known key found for this signature in database
GPG Key ID: 28BA6AEE539ECE2E
2 changed files with 8 additions and 9 deletions

View File

@ -2988,9 +2988,6 @@ class Client extends MatrixApi {
chatUpdate.unreadNotifications?.notificationCount ?? 0; chatUpdate.unreadNotifications?.notificationCount ?? 0;
rooms[roomIndex].highlightCount = rooms[roomIndex].highlightCount =
chatUpdate.unreadNotifications?.highlightCount ?? 0; chatUpdate.unreadNotifications?.highlightCount ?? 0;
if (chatUpdate.timeline?.prevBatch != null) {
rooms[roomIndex].prev_batch = chatUpdate.timeline?.prevBatch;
}
final summary = chatUpdate.summary; final summary = chatUpdate.summary;
if (summary != null) { if (summary != null) {

View File

@ -1322,7 +1322,6 @@ class Room {
); );
if (onHistoryReceived != null) onHistoryReceived(); if (onHistoryReceived != null) onHistoryReceived();
final newPrevBatch = direction == Direction.b ? resp.end : resp.start;
Future<void> loadFn() async { Future<void> loadFn() async {
if (!((resp.chunk.isNotEmpty) && resp.end != null)) return; if (!((resp.chunk.isNotEmpty) && resp.end != null)) return;
@ -1340,7 +1339,8 @@ class Room {
events: direction == Direction.b events: direction == Direction.b
? resp.chunk ? resp.chunk
: resp.chunk.reversed.toList(), : resp.chunk.reversed.toList(),
prevBatch: newPrevBatch, prevBatch:
direction == Direction.b ? resp.end : resp.start,
), ),
), ),
} }
@ -1354,21 +1354,23 @@ class Room {
events: direction == Direction.b events: direction == Direction.b
? resp.chunk ? resp.chunk
: resp.chunk.reversed.toList(), : resp.chunk.reversed.toList(),
prevBatch: newPrevBatch, prevBatch:
direction == Direction.b ? resp.end : resp.start,
), ),
), ),
} }
: null, : null,
), ),
), ),
direction: Direction.b, direction: direction,
); );
} }
if (client.database != null) { if (client.database != null) {
await client.database?.transaction(() async { await client.database?.transaction(() async {
if (storeInDatabase) { if (storeInDatabase && direction == Direction.b) {
await client.database?.setRoomPrevBatch(newPrevBatch, id, client); this.prev_batch = resp.end;
await client.database?.setRoomPrevBatch(resp.end, id, client);
} }
await loadFn(); await loadFn();
}); });