Skip to content

Commit c00b2db

Browse files
committed
test(sdk): Test SlidingSyncRoom::prev_batch.
1 parent e7e66dc commit c00b2db

File tree

1 file changed

+12
-1
lines changed
  • crates/matrix-sdk/src/sliding_sync

1 file changed

+12
-1
lines changed

crates/matrix-sdk/src/sliding_sync/room.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ impl SlidingSyncRoom {
108108
&self.inner.required_state
109109
}
110110

111+
/// Get the previous batch.
112+
fn prev_batch(&self) -> Option<&String> {
113+
self.inner.prev_batch.as_ref()
114+
}
115+
111116
/// `Timeline` of this room
112117
pub async fn timeline(&self) -> Option<Timeline> {
113118
Some(self.timeline_builder()?.track_read_marker_and_receipts().build().await)
@@ -126,7 +131,7 @@ impl SlidingSyncRoom {
126131
if let Some(room) = self.client.get_room(&self.room_id) {
127132
Some(
128133
Timeline::builder(&room)
129-
.events(self.inner.prev_batch.clone(), self.timeline_queue.clone()),
134+
.events(self.prev_batch().cloned(), self.timeline_queue.clone()),
130135
)
131136
} else if let Some(invited_room) = self.client.get_invited_room(&self.room_id) {
132137
Some(Timeline::builder(&invited_room).events(None, Vector::new()))
@@ -383,6 +388,12 @@ mod tests {
383388
receives room_response!({"highlight_count": 42});
384389
_ = Some(uint!(42));
385390
}
391+
392+
test_prev_batch {
393+
prev_batch() = None;
394+
receives room_response!({"prev_batch": "t111_222_333"});
395+
_ = Some(&"t111_222_333".to_string());
396+
}
386397
}
387398

388399
#[tokio::test]

0 commit comments

Comments
 (0)