1 files changed, 5 insertions, 2 deletions
diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py
index f15987b265..28c7523b7c 100644
--- a/synapse/handlers/room_list.py
+++ b/synapse/handlers/room_list.py
@@ -238,9 +238,12 @@ class RoomListHandler(BaseHandler):
addition *= -1
try:
- new_limit = sorted_rooms.index(last_room_id) + addition
- if new_limit >= len(sorted_rooms):
+ if sorted_rooms.index(last_room_id) == len(sorted_rooms):
new_limit = None
+ else:
+ new_limit = sorted_rooms.index(last_room_id) + addition
+ if new_limit >= len(sorted_rooms):
+ new_limit = len(sorted_rooms)
except ValueError:
pass
|