From 001523ec811a75f9d6d57dd8ffabc04af7803443 Mon Sep 17 00:00:00 2001 From: morguldir Date: Sat, 24 Aug 2024 05:23:51 +0200 Subject: [PATCH] Avoid panicing during sliding sync if the user isn't in any rooms --- src/api/client/sync.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/client/sync.rs b/src/api/client/sync.rs index b069a77e..a0a1749b 100644 --- a/src/api/client/sync.rs +++ b/src/api/client/sync.rs @@ -1309,7 +1309,11 @@ pub(crate) async fn sync_events_v4_route( r.0, UInt::try_from(all_joined_rooms.len().saturating_sub(1)).unwrap_or(UInt::MAX), ); - let room_ids = all_joined_rooms[usize_from_ruma(r.0)..=usize_from_ruma(r.1)].to_vec(); + let room_ids = if !all_joined_rooms.is_empty() { + all_joined_rooms[usize_from_ruma(r.0)..=usize_from_ruma(r.1)].to_vec() + } else { + Vec::new() + }; new_known_rooms.extend(room_ids.iter().cloned()); for room_id in &room_ids { let todo_room = todo_rooms