From 6f738a4ab854cbae206ca3b0f4476aaf99c78202 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 23 Jul 2024 11:38:09 +0100 Subject: Apply suggestions from code review Co-authored-by: Eric Eastwood --- synapse/handlers/sliding_sync.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/synapse/handlers/sliding_sync.py b/synapse/handlers/sliding_sync.py index 1238592917..543a1f8836 100644 --- a/synapse/handlers/sliding_sync.py +++ b/synapse/handlers/sliding_sync.py @@ -640,7 +640,7 @@ class SlidingSyncHandler: elif from_token: connection_token = from_token.connection else: - # Initial sync without a `from_token` starts a `0` + # Initial sync without a `from_token` starts at `0` connection_token = 0 return SlidingSyncResult( @@ -1467,8 +1467,9 @@ class SlidingSyncHandler: timeline_events, new_room_key = await self.store.paginate_room_events( room_id=room_id, - # Because we want the latest events first the bounds are - # reversed. + # The bounds are reversed so we can paginate backwards + # (from newer to older events) starting at to_bound. + # This ensures we fill the `limit` with the newest events first, from_key=to_bound, to_key=from_bound, direction=Direction.BACKWARDS, -- cgit 1.5.1