Skip to content

Commit

Permalink
chore(sdk): Remove the useless SlidingSyncList::get_room_id method.
Browse files Browse the repository at this point in the history
This patch removes the useless `SlidingSyncList::get_room_id` method as
I don't see how it can be useful for anybody. It's mostly dead public
code, let's clean that up.
  • Loading branch information
Hywan committed Jun 17, 2024
1 parent 6ecefd6 commit 304c225
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions crates/matrix-sdk/src/sliding_sync/list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,6 @@ impl SlidingSyncList {
Observable::subscribe(&self.inner.maximum_number_of_rooms.read().unwrap())
}

/// Return the `room_id` at the given index.
pub fn get_room_id(&self, index: usize) -> Option<OwnedRoomId> {
self.inner
.room_list
.read()
.unwrap()
.get(index)
.and_then(|room_list_entry| room_list_entry.as_room_id().map(ToOwned::to_owned))
}

/// Calculate the next request and return it.
///
/// The next request is entirely calculated based on the request generator
Expand Down Expand Up @@ -990,35 +980,6 @@ mod tests {
assert_eq!(list.inner.sticky.read().unwrap().data().timeline_limit(), None);
}

#[test]
fn test_sliding_sync_get_room_id() {
let (sender, _receiver) = channel(1);

let mut list = SlidingSyncList::builder("foo")
.sync_mode(SlidingSyncMode::new_selective().add_range(0..=1))
.build(sender);

let room0 = room_id!("!room0:bar.org");
let room1 = room_id!("!room1:bar.org");

// Simulate a request.
let _ = list.next_request(&mut LazyTransactionId::new());

// A new response.
let sync0: v4::SyncOp = serde_json::from_value(json!({
"op": SlidingOp::Sync,
"range": [0, 1],
"room_ids": [room0, room1],
}))
.unwrap();

list.update(Some(6), &[sync0], &[]).unwrap();

assert_eq!(list.get_room_id(0), Some(room0.to_owned()));
assert_eq!(list.get_room_id(1), Some(room1.to_owned()));
assert_eq!(list.get_room_id(2), None);
}

macro_rules! assert_ranges {
(
list = $list:ident,
Expand Down

0 comments on commit 304c225

Please sign in to comment.