Skip to content

Commit

Permalink
refactor(base): Remove the sliding_sync::http re-export.
Browse files Browse the repository at this point in the history
This patch removes the `pub use ruma::api::client::sync::sync_events::v5
as http` re-export in `matrix_sdk_base::sliding_sync`.
  • Loading branch information
Hywan committed Feb 5, 2025
1 parent 5f4e046 commit a1a3d95
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 40 deletions.
12 changes: 7 additions & 5 deletions crates/matrix-sdk-base/src/sliding_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ use std::ops::Deref;

#[cfg(feature = "e2e-encryption")]
use matrix_sdk_common::deserialized_responses::TimelineEvent;
pub use ruma::api::client::sync::sync_events::v5 as http;
use ruma::{
api::client::sync::sync_events::v3::{self, InvitedRoom, KnockedRoom},
api::client::sync::sync_events::{
v3::{self, InvitedRoom, KnockedRoom},
v5 as http,
},
events::{
room::member::MembershipState, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
AnySyncStateEvent,
Expand All @@ -31,7 +33,7 @@ use ruma::{
JsOption, OwnedRoomId, RoomId, UserId,
};
#[cfg(feature = "e2e-encryption")]
use ruma::{api::client::sync::sync_events::v5, events::AnyToDeviceEvent, events::StateEventType};
use ruma::{events::AnyToDeviceEvent, events::StateEventType};
use tracing::{instrument, trace, warn};

use super::BaseClient;
Expand Down Expand Up @@ -65,8 +67,8 @@ impl BaseClient {
/// Returns whether any change happened.
pub async fn process_sliding_sync_e2ee(
&self,
to_device: Option<&v5::response::ToDevice>,
e2ee: &v5::response::E2EE,
to_device: Option<&http::response::ToDevice>,
e2ee: &http::response::E2EE,
) -> Result<Option<Vec<Raw<AnyToDeviceEvent>>>> {
if to_device.is_none() && e2ee.is_empty() {
return Ok(None);
Expand Down
3 changes: 1 addition & 2 deletions crates/matrix-sdk-ui/src/encryption_sync_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ use async_stream::stream;
use futures_core::stream::Stream;
use futures_util::{pin_mut, StreamExt};
use matrix_sdk::{sleep::sleep, Client, SlidingSync, LEASE_DURATION_MS};
use matrix_sdk_base::sliding_sync::http;
use ruma::assign;
use ruma::{api::client::sync::sync_events::v5 as http, assign};
use tokio::sync::OwnedMutexGuard;
use tracing::{debug, instrument, trace, Span};

Expand Down
5 changes: 2 additions & 3 deletions crates/matrix-sdk-ui/src/notification_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ use futures_util::{pin_mut, StreamExt as _};
use matrix_sdk::{
room::Room, sleep::sleep, Client, ClientBuildError, SlidingSyncList, SlidingSyncMode,
};
use matrix_sdk_base::{
deserialized_responses::TimelineEvent, sliding_sync::http, RoomState, StoreError,
};
use matrix_sdk_base::{deserialized_responses::TimelineEvent, RoomState, StoreError};
use ruma::{
api::client::sync::sync_events::v5 as http,
assign,
directory::RoomTypeFilter,
events::{
Expand Down
6 changes: 4 additions & 2 deletions crates/matrix-sdk-ui/src/room_list_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ use matrix_sdk::{
event_cache::EventCacheError, timeout::timeout, Client, Error as SlidingSyncError, SlidingSync,
SlidingSyncList, SlidingSyncMode,
};
use matrix_sdk_base::sliding_sync::http;
pub use room::*;
pub use room_list::*;
use ruma::{assign, directory::RoomTypeFilter, events::StateEventType, OwnedRoomId, RoomId, UInt};
use ruma::{
api::client::sync::sync_events::v5 as http, assign, directory::RoomTypeFilter,
events::StateEventType, OwnedRoomId, RoomId, UInt,
};
pub use state::*;
use thiserror::Error;
use tracing::debug;
Expand Down
5 changes: 3 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/event_item/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,13 +827,14 @@ mod tests {
use assert_matches2::assert_let;
use matrix_sdk::test_utils::logged_in_client;
use matrix_sdk_base::{
deserialized_responses::TimelineEvent, latest_event::LatestEvent, sliding_sync::http,
MinimalStateEvent, OriginalMinimalStateEvent,
deserialized_responses::TimelineEvent, latest_event::LatestEvent, MinimalStateEvent,
OriginalMinimalStateEvent,
};
use matrix_sdk_test::{
async_test, event_factory::EventFactory, sync_state_event, sync_timeline_event,
};
use ruma::{
api::client::sync::sync_events::v5 as http,
event_id,
events::{
room::{
Expand Down
6 changes: 2 additions & 4 deletions crates/matrix-sdk/src/sliding_sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ are **inclusive**) like so:

```rust
# use matrix_sdk::sliding_sync::{SlidingSyncList, SlidingSyncMode};
use matrix_sdk_base::sliding_sync::http;
use ruma::assign;
use ruma::{api::client::sync::sync_events::v5 as http, assign};

let list_builder = SlidingSyncList::builder("main_list")
.sync_mode(SlidingSyncMode::new_selective().add_range(0..=9))
Expand Down Expand Up @@ -326,8 +325,7 @@ whenever a new set of timeline items is received by the server.

```rust,no_run
use matrix_sdk::{Client, sliding_sync::{SlidingSyncList, SlidingSyncMode, Version}};
use matrix_sdk_base::sliding_sync::http;
use ruma::{assign, events::StateEventType};
use ruma::{api::client::sync::sync_events::v5 as http, assign, events::StateEventType};
use tracing::{warn, error, info, debug};
use futures_util::{pin_mut, StreamExt};
use url::Url;
Expand Down
3 changes: 1 addition & 2 deletions crates/matrix-sdk/src/sliding_sync/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use std::{
time::Duration,
};

use matrix_sdk_base::sliding_sync::http;
use matrix_sdk_common::timer;
use ruma::OwnedRoomId;
use ruma::{api::client::sync::sync_events::v5 as http, OwnedRoomId};
use tokio::sync::{broadcast::channel, Mutex as AsyncMutex, RwLock as AsyncRwLock};

use super::{
Expand Down
6 changes: 4 additions & 2 deletions crates/matrix-sdk/src/sliding_sync/client.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::collections::BTreeMap;

use imbl::Vector;
use matrix_sdk_base::{sliding_sync::http, sync::SyncResponse, PreviousEventsProvider};
use matrix_sdk_base::{sync::SyncResponse, PreviousEventsProvider};
use ruma::{
api::client::discovery::get_supported_versions, events::AnyToDeviceEvent, serde::Raw,
api::client::{discovery::get_supported_versions, sync::sync_events::v5 as http},
events::AnyToDeviceEvent,
serde::Raw,
OwnedRoomId,
};
use tracing::error;
Expand Down
3 changes: 1 addition & 2 deletions crates/matrix-sdk/src/sliding_sync/list/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use std::{
};

use eyeball::{Observable, SharedObservable};
use matrix_sdk_base::sliding_sync::http;
use ruma::events::StateEventType;
use ruma::{api::client::sync::sync_events::v5 as http, events::StateEventType};
use tokio::sync::broadcast::Sender;

use super::{
Expand Down
3 changes: 1 addition & 2 deletions crates/matrix-sdk/src/sliding_sync/list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use std::{

use eyeball::{Observable, SharedObservable, Subscriber};
use futures_core::Stream;
use matrix_sdk_base::sliding_sync::http;
use ruma::{assign, TransactionId};
use ruma::{api::client::sync::sync_events::v5 as http, assign, TransactionId};
use serde::{Deserialize, Serialize};
use tokio::sync::broadcast::Sender;
use tracing::{instrument, warn};
Expand Down
3 changes: 1 addition & 2 deletions crates/matrix-sdk/src/sliding_sync/list/sticky.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use matrix_sdk_base::sliding_sync::http;
use ruma::events::StateEventType;
use ruma::{api::client::sync::sync_events::v5 as http, events::StateEventType};

use crate::sliding_sync::sticky_parameters::StickyData;

Expand Down
6 changes: 4 additions & 2 deletions crates/matrix-sdk/src/sliding_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ use std::{
use async_stream::stream;
pub use client::{Version, VersionBuilder};
use futures_core::stream::Stream;
pub use matrix_sdk_base::sliding_sync::http;
use matrix_sdk_common::{deserialized_responses::TimelineEvent, executor::spawn, timer};
use ruma::{api::client::error::ErrorKind, assign, OwnedRoomId, RoomId};
use ruma::{
api::client::{error::ErrorKind, sync::sync_events::v5 as http},
assign, OwnedRoomId, RoomId,
};
use serde::{Deserialize, Serialize};
use tokio::{
select,
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk/src/sliding_sync/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::{
};

use eyeball_im::Vector;
use matrix_sdk_base::{deserialized_responses::TimelineEvent, sliding_sync::http};
use ruma::{OwnedRoomId, RoomId};
use matrix_sdk_base::deserialized_responses::TimelineEvent;
use ruma::{api::client::sync::sync_events::v5 as http, OwnedRoomId, RoomId};
use serde::{Deserialize, Serialize};

/// The state of a [`SlidingSyncRoom`].
Expand Down
13 changes: 8 additions & 5 deletions crates/matrix-sdk/tests/integration/room_preview.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use js_int::uint;
use matrix_sdk::{config::SyncSettings, test_utils::logged_in_client_with_server};
use matrix_sdk_base::{sliding_sync, RoomState};
use matrix_sdk_base::RoomState;
use matrix_sdk_test::{
async_test, InvitedRoomBuilder, JoinedRoomBuilder, KnockedRoomBuilder, SyncResponseBuilder,
};
use ruma::{
api::client::sync::sync_events::v5::response::Hero, assign,
events::room::member::MembershipState, owned_user_id, room_id, space::SpaceRoomJoinRule,
api::client::sync::sync_events::{v5 as sliding_sync_http, v5::response::Hero},
assign,
events::room::member::MembershipState,
owned_user_id, room_id,
space::SpaceRoomJoinRule,
RoomId,
};
use serde_json::json;
Expand Down Expand Up @@ -120,7 +123,7 @@ async fn test_room_preview_computes_name_if_room_is_known() {
let room_id = room_id!("!room:localhost");

// Given a room with no name but a hero
let room = assign!(sliding_sync::http::response::Room::new(), {
let room = assign!(sliding_sync_http::response::Room::new(), {
name: None,
heroes: Some(vec![assign!(Hero::new(owned_user_id!("@alice:matrix.org")), {
name: Some("Alice".to_owned()),
Expand All @@ -129,7 +132,7 @@ async fn test_room_preview_computes_name_if_room_is_known() {
joined_count: Some(uint!(1)),
invited_count: Some(uint!(1)),
});
let mut response = sliding_sync::http::Response::new("0".to_owned());
let mut response = sliding_sync_http::Response::new("0".to_owned());
response.rooms.insert(room_id.to_owned(), room);

client.process_sliding_sync_test_helper(&response).await.expect("Failed to process sync");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ use matrix_sdk::{
test_utils::{logged_in_client_with_server, mocks::MatrixMockServer},
Client, Room, RoomInfo, RoomMemberships, RoomState, SlidingSyncList, SlidingSyncMode,
};
use matrix_sdk_base::{
ruma::{owned_room_id, room_alias_id},
sliding_sync::http,
use matrix_sdk_base::ruma::{
api::client::sync::sync_events::v5 as http, owned_room_id, room_alias_id,
};
use matrix_sdk_test::async_test;
use matrix_sdk_ui::{
Expand Down

0 comments on commit a1a3d95

Please sign in to comment.