Merge pull request #2049 from famedly/karthi/room-prev-batch-fix

fix: room prev_batch set incorrectly follow-up
This commit is contained in:
Krille-chan 2025-03-13 07:37:05 +01:00 committed by GitHub
commit acf6c990a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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();
}); });