Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process rooms' read status client-side #2953

Merged
merged 10 commits into from
Dec 21, 2023
10 changes: 6 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/event_item/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ mod tests {
}

#[async_test]
async fn latest_message_event_can_be_wrapped_as_a_timeline_item_with_sender_from_the_storage() {
async fn test_latest_message_event_can_be_wrapped_as_a_timeline_item_with_sender_from_the_storage(
) {
// Given a sync event that is suitable to be used as a latest_event, and a room
// with a member event for the sender

Expand All @@ -574,7 +575,7 @@ mod tests {

// And the room is stored in the client so it can be extracted when needed
let response = response_with_room(room_id, room).await;
client.process_sliding_sync(&response).await.unwrap();
client.process_sliding_sync_test_helper(&response).await.unwrap();

// When we construct a timeline event from it
let timeline_item =
Expand All @@ -595,7 +596,8 @@ mod tests {
}

#[async_test]
async fn latest_message_event_can_be_wrapped_as_a_timeline_item_with_sender_from_the_cache() {
async fn test_latest_message_event_can_be_wrapped_as_a_timeline_item_with_sender_from_the_cache(
) {
// Given a sync event that is suitable to be used as a latest_event, a room, and
// a member event for the sender (which isn't part of the room yet).

Expand All @@ -617,7 +619,7 @@ mod tests {

// And the room is stored in the client so it can be extracted when needed
let response = response_with_room(room_id, room).await;
client.process_sliding_sync(&response).await.unwrap();
client.process_sliding_sync_test_helper(&response).await.unwrap();

// When we construct a timeline event from it
let timeline_item = EventTimelineItem::from_latest_event(
Expand Down
12 changes: 8 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/sliding_sync_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ mod tests {
}

#[async_test]
async fn latest_message_event_is_wrapped_as_a_timeline_item() {
async fn test_latest_message_event_is_wrapped_as_a_timeline_item() {
// Given a room exists, and an event came in through a sync
let room_id = room_id!("!r:x.uk");
let user_id = user_id!("@s:o.uk");
let client = logged_in_client(None).await;
let event = message_event(room_id, user_id, "**My msg**", "<b>My msg</b>", 122343);
process_event_via_sync(room_id, event, &client).await;
process_event_via_sync_test_helper(room_id, event, &client).await;

// When we ask for the latest event in the room
let room = SlidingSyncRoom::new(
Expand All @@ -118,11 +118,15 @@ mod tests {
}
}

async fn process_event_via_sync(room_id: &RoomId, event: SyncTimelineEvent, client: &Client) {
async fn process_event_via_sync_test_helper(
room_id: &RoomId,
event: SyncTimelineEvent,
client: &Client,
) {
let mut room = v4::SlidingSyncRoom::new();
room.timeline.push(event.event);
let response = response_with_room(room_id, room).await;
client.process_sliding_sync(&response).await.unwrap();
client.process_sliding_sync_test_helper(&response).await.unwrap();
}

fn message_event(
Expand Down
5 changes: 4 additions & 1 deletion crates/matrix-sdk/src/sliding_sync/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ impl Client {
/// If you need to handle encryption too, use the internal
/// `SlidingSyncResponseProcessor` instead.
#[instrument(skip(self, response))]
pub async fn process_sliding_sync(&self, response: &v4::Response) -> Result<SyncResponse> {
pub async fn process_sliding_sync_test_helper(
bnjbvr marked this conversation as resolved.
Show resolved Hide resolved
&self,
response: &v4::Response,
) -> Result<SyncResponse> {
let response = self.base_client().process_sliding_sync(response, &()).await?;

debug!("done processing on base_client");
Expand Down