Skip to content

Commit

Permalink
Select to_key if to_key else from_key
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLittleMods committed Jul 2, 2024
1 parent e419587 commit 2bd6cba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions synapse/storage/databases/main/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1827,15 +1827,19 @@ async def paginate_room_events(
and to_key is not None
and to_key.is_before_or_eq(from_key)
):
return [], from_key
# Token selection matches what we do in `_paginate_room_events_txn` if there
# are no rows
return [], to_key if to_key else from_key
# Or vice-versa, if we're looking backwards and our `from_key` is already before
# our `to_key`.
elif (
direction == Direction.BACKWARDS
and to_key is not None
and from_key.is_before_or_eq(to_key)
):
return [], from_key
# Token selection matches what we do in `_paginate_room_events_txn` if there
# are no rows
return [], to_key if to_key else from_key

rows, token = await self.db_pool.runInteraction(
"paginate_room_events",
Expand Down

0 comments on commit 2bd6cba

Please sign in to comment.