Skip to content

Commit 8b2088f

Browse files
authored
feat(wasm): Eliminate some unecessary wasm removals from matrix-sdk crate (#5169)
1 parent d38f409 commit 8b2088f

File tree

11 files changed

+35
-29
lines changed

11 files changed

+35
-29
lines changed

crates/matrix-sdk/src/authentication/oauth/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ use error::{
174174
OAuthAuthorizationCodeError, OAuthClientRegistrationError, OAuthDiscoveryError,
175175
OAuthTokenRevocationError, RedirectUriQueryParseError,
176176
};
177-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
177+
#[cfg(feature = "e2e-encryption")]
178178
use matrix_sdk_base::crypto::types::qr_login::QrCodeData;
179179
#[cfg(feature = "e2e-encryption")]
180180
use matrix_sdk_base::once_cell::sync::OnceCell;
@@ -208,15 +208,15 @@ mod cross_process;
208208
pub mod error;
209209
mod http_client;
210210
mod oidc_discovery;
211-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
211+
#[cfg(feature = "e2e-encryption")]
212212
pub mod qrcode;
213213
pub mod registration;
214214
#[cfg(all(test, not(target_family = "wasm")))]
215215
mod tests;
216216

217217
#[cfg(feature = "e2e-encryption")]
218218
use self::cross_process::{CrossProcessRefreshLockGuard, CrossProcessRefreshManager};
219-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
219+
#[cfg(feature = "e2e-encryption")]
220220
use self::qrcode::LoginWithQrCode;
221221
pub use self::{
222222
account_management_url::{AccountManagementActionFull, AccountManagementUrlBuilder},
@@ -454,7 +454,7 @@ impl OAuth {
454454
/// println!("Successfully logged in: {:?} {:?}", client.user_id(), client.device_id());
455455
/// # anyhow::Ok(()) };
456456
/// ```
457-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
457+
#[cfg(feature = "e2e-encryption")]
458458
pub fn login_with_qr_code<'a>(
459459
&'a self,
460460
data: &'a QrCodeData,
@@ -1154,7 +1154,7 @@ impl OAuth {
11541154

11551155
/// Request codes from the authorization server for logging in with another
11561156
/// device.
1157-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
1157+
#[cfg(feature = "e2e-encryption")]
11581158
async fn request_device_authorization(
11591159
&self,
11601160
server_metadata: &AuthorizationServerMetadata,
@@ -1182,7 +1182,7 @@ impl OAuth {
11821182
}
11831183

11841184
/// Exchange the device code against an access token.
1185-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
1185+
#[cfg(feature = "e2e-encryption")]
11861186
async fn exchange_device_code(
11871187
&self,
11881188
server_metadata: &AuthorizationServerMetadata,

crates/matrix-sdk/src/authentication/oauth/qrcode/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl<'a> LoginWithQrCode<'a> {
327327
}
328328
}
329329

330-
#[cfg(test)]
330+
#[cfg(all(test, not(target_family = "wasm")))]
331331
mod test {
332332
use assert_matches2::{assert_let, assert_matches};
333333
use futures_util::{join, StreamExt};

crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl RendezvousChannel {
284284
}
285285
}
286286

287-
#[cfg(test)]
287+
#[cfg(all(test, not(target_family = "wasm")))]
288288
mod test {
289289
use matrix_sdk_test::async_test;
290290
use serde_json::json;

crates/matrix-sdk/src/authentication/oauth/qrcode/secure_channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl EstablishedSecureChannel {
226226
}
227227
}
228228

229-
#[cfg(test)]
229+
#[cfg(all(test, not(target_family = "wasm")))]
230230
pub(super) mod test {
231231
use std::sync::{
232232
atomic::{AtomicU8, Ordering},

crates/matrix-sdk/src/client/futures.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
use std::{fmt::Debug, future::IntoFuture};
1818

19-
use eyeball::SharedObservable;
20-
#[cfg(not(target_family = "wasm"))]
21-
use eyeball::Subscriber;
19+
use eyeball::{SharedObservable, Subscriber};
2220
use js_int::UInt;
2321
use matrix_sdk_common::{boxed_into_future, SendOutsideWasm, SyncOutsideWasm};
2422
use oauth2::{basic::BasicErrorResponseType, RequestTokenError};
@@ -71,7 +69,6 @@ impl<R> SendRequest<R> {
7169

7270
/// Get a subscriber to observe the progress of sending the request
7371
/// body.
74-
#[cfg(not(target_family = "wasm"))]
7572
pub fn subscribe_to_send_progress(&self) -> Subscriber<TransmissionProgress> {
7673
self.send_progress.subscribe()
7774
}

crates/matrix-sdk/src/encryption/futures.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
use std::{future::IntoFuture, io::Read};
2121

22-
use eyeball::SharedObservable;
23-
#[cfg(not(target_family = "wasm"))]
24-
use eyeball::Subscriber;
22+
use eyeball::{SharedObservable, Subscriber};
2523
use matrix_sdk_common::boxed_into_future;
2624
use ruma::events::room::{EncryptedFile, EncryptedFileInit};
2725

@@ -66,7 +64,6 @@ impl<'a, R: ?Sized> UploadEncryptedFile<'a, R> {
6664

6765
/// Get a subscriber to observe the progress of sending the request
6866
/// body.
69-
#[cfg(not(target_family = "wasm"))]
7067
pub fn subscribe_to_send_progress(&self) -> Subscriber<TransmissionProgress> {
7168
self.send_progress.subscribe()
7269
}

crates/matrix-sdk/src/encryption/identities/users.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl UserIdentity {
108108
Self { inner: identity, client }
109109
}
110110

111-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
111+
#[cfg(feature = "e2e-encryption")]
112112
pub(crate) fn underlying_identity(&self) -> CryptoUserIdentity {
113113
self.inner.clone()
114114
}

crates/matrix-sdk/src/encryption/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,6 @@ impl Encryption {
723723
}
724724
}
725725

726-
#[cfg(not(target_family = "wasm"))]
727726
pub(crate) async fn import_secrets_bundle(
728727
&self,
729728
bundle: &matrix_sdk_base::crypto::types::SecretsBundle,
@@ -1691,7 +1690,6 @@ impl Encryption {
16911690
/// **Warning**: Do not use this method if we're already calling
16921691
/// [`Client::send_outgoing_request()`]. This method is intended for
16931692
/// explicitly uploading the device keys before starting a sync.
1694-
#[cfg(not(target_family = "wasm"))]
16951693
pub(crate) async fn ensure_device_keys_upload(&self) -> Result<()> {
16961694
let olm = self.client.olm_machine().await;
16971695
let olm = olm.as_ref().ok_or(Error::NoOlmMachine)?;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
//! Facility to track changes to the identity of members of rooms.
16-
#![cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
16+
#![cfg(feature = "e2e-encryption")]
1717

1818
use std::collections::BTreeMap;
1919

@@ -193,7 +193,7 @@ fn wrap_room_member_events(
193193
(drop_guard, ReceiverStream::new(receiver))
194194
}
195195

196-
#[cfg(test)]
196+
#[cfg(all(test, not(target_family = "wasm")))]
197197
mod tests {
198198
use std::time::Duration;
199199

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ use eyeball::SharedObservable;
2828
use futures_core::Stream;
2929
use futures_util::{future::join_all, stream::FuturesUnordered};
3030
use http::StatusCode;
31-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
31+
#[cfg(feature = "e2e-encryption")]
3232
pub use identity_status_changes::IdentityStatusChanges;
33-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
33+
#[cfg(feature = "e2e-encryption")]
3434
use matrix_sdk_base::crypto::{IdentityStatusChange, RoomIdentityProvider, UserIdentity};
3535
#[cfg(feature = "e2e-encryption")]
3636
use matrix_sdk_base::{
@@ -47,7 +47,7 @@ use matrix_sdk_base::{
4747
ComposerDraft, EncryptionState, RoomInfoNotableUpdateReasons, RoomMemberships, SendOutsideWasm,
4848
StateChanges, StateStoreDataKey, StateStoreDataValue,
4949
};
50-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
50+
#[cfg(feature = "e2e-encryption")]
5151
use matrix_sdk_common::BoxFuture;
5252
use matrix_sdk_common::{
5353
deserialized_responses::TimelineEvent,
@@ -583,7 +583,7 @@ impl Room {
583583
/// Note that if a user who is in pin violation leaves the room, a `Pinned`
584584
/// update is sent, to indicate that the warning should be removed, even
585585
/// though the user's identity is not necessarily pinned.
586-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
586+
#[cfg(feature = "e2e-encryption")]
587587
pub async fn subscribe_to_identity_status_changes(
588588
&self,
589589
) -> Result<impl Stream<Item = Vec<IdentityStatusChange>>> {
@@ -3709,7 +3709,7 @@ impl Room {
37093709
}
37103710
}
37113711

3712-
#[cfg(all(feature = "e2e-encryption", not(target_family = "wasm")))]
3712+
#[cfg(feature = "e2e-encryption")]
37133713
impl RoomIdentityProvider for Room {
37143714
fn is_member<'a>(&'a self, user_id: &'a UserId) -> BoxFuture<'a, bool> {
37153715
Box::pin(async { self.get_member(user_id).await.unwrap_or(None).is_some() })

0 commit comments

Comments
 (0)