diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index a1afc8156..b035a832a 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -239,7 +239,7 @@ impl BaseClient { } #[cfg(feature = "e2e-encryption")] - async fn handle_unenecrypted_verification_event( + async fn handle_unencrypted_verification_event( &self, event: &AnySyncMessageLikeEvent, room_id: &RoomId, @@ -353,12 +353,12 @@ impl BaseClient { ruma::events::room::message::MessageType::VerificationRequest( _, ) => { - self.handle_unenecrypted_verification_event(e, room_id).await?; + self.handle_unencrypted_verification_event(e, room_id).await?; } _ => (), }, _ if e.event_type().to_string().starts_with("m.key.verification") => { - self.handle_unenecrypted_verification_event(e, room_id).await?; + self.handle_unencrypted_verification_event(e, room_id).await?; } _ => (), }, diff --git a/crates/matrix-sdk-base/src/store/memory_store.rs b/crates/matrix-sdk-base/src/store/memory_store.rs index fad2aed61..d9091ec3e 100644 --- a/crates/matrix-sdk-base/src/store/memory_store.rs +++ b/crates/matrix-sdk-base/src/store/memory_store.rs @@ -258,31 +258,31 @@ impl MemoryStore { MembershipState::Join => { self.stripped_joined_user_ids .entry(room.clone()) - .or_insert_with(DashSet::new) + .or_default() .insert(event.state_key.clone()); self.stripped_invited_user_ids .entry(room.clone()) - .or_insert_with(DashSet::new) + .or_default() .remove(&event.state_key); } MembershipState::Invite => { self.stripped_invited_user_ids .entry(room.clone()) - .or_insert_with(DashSet::new) + .or_default() .insert(event.state_key.clone()); self.stripped_joined_user_ids .entry(room.clone()) - .or_insert_with(DashSet::new) + .or_default() .remove(&event.state_key); } _ => { self.stripped_joined_user_ids .entry(room.clone()) - .or_insert_with(DashSet::new) + .or_default() .remove(&event.state_key); self.stripped_invited_user_ids .entry(room.clone()) - .or_insert_with(DashSet::new) + .or_default() .remove(&event.state_key); } } diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index 3d5869460..fb8f17d46 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -152,8 +152,8 @@ pub(crate) struct ClientInner { /// flight per room. #[cfg(feature = "e2e-encryption")] pub(crate) group_session_locks: DashMap>>, - #[cfg(feature = "e2e-encryption")] /// Lock making sure we're only doing one key claim request at a time. + #[cfg(feature = "e2e-encryption")] pub(crate) key_claim_lock: Mutex<()>, pub(crate) members_request_locks: DashMap>>, pub(crate) typing_notice_times: DashMap, @@ -256,8 +256,8 @@ impl Client { /// * `transaction_id` - The id of the transaction, used to guard against /// the same transaction being sent twice. This guarding currently isn't /// implemented. - /// * `incoming_transaction` - The sync response converted from a - /// transaction received from the homeserver. + /// * `sync_response` - The sync response converted from a transaction + /// received from the homeserver. /// /// [transaction]: https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid #[cfg(feature = "appservice")] @@ -590,6 +590,12 @@ impl Client { /// // You can omit any or all arguments after the first. /// }); /// + /// // Registering a temporary event handler: + /// let handle = client.add_event_handler(|ev: SyncRoomMessageEvent| async move { + /// /* Event handler */ + /// }); + /// client.remove_event_handler(handle); + /// /// // Custom events work exactly the same way, you just need to declare /// // the content struct and use the EventContent derive macro on it. /// #[derive(Clone, Debug, Deserialize, Serialize, EventContent)] diff --git a/crates/matrix-sdk/src/event_handler/mod.rs b/crates/matrix-sdk/src/event_handler/mod.rs index 045f729fa..22fb905f0 100644 --- a/crates/matrix-sdk/src/event_handler/mod.rs +++ b/crates/matrix-sdk/src/event_handler/mod.rs @@ -388,7 +388,7 @@ impl Client { None => (HandlerKind::MessageLike, HandlerKind::message_like_redacted(redacted)), }; - let raw_event = &item.event.json(); + let raw_event = item.event.json(); let encryption_info = item.encryption_info.as_ref(); // Event handlers for possibly-redacted timeline events diff --git a/crates/matrix-sdk/src/room/common.rs b/crates/matrix-sdk/src/room/common.rs index 1d01b20a9..bc89d4d0d 100644 --- a/crates/matrix-sdk/src/room/common.rs +++ b/crates/matrix-sdk/src/room/common.rs @@ -108,7 +108,7 @@ impl Common { /// /// Returns a [`Result`] containing an instance of [`Left`] if successful. /// - /// Only invited and joined rooms can be left + /// Only invited and joined rooms can be left. #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/docs/sync_running.md"))] pub(crate) async fn leave(&self) -> Result { let request = leave_room::v3::Request::new(self.inner.room_id()); @@ -153,14 +153,14 @@ impl Common { let option = TryStreamExt::try_next(&mut rx).await?; - Ok(option.expect("receive joined room result from event handler")) + Ok(option.expect("receive left room result from event handler")) } /// Join this room. /// /// Returns a [`Result`] containing an instance of [`Joined`][room::Joined] /// if successful. - /// Only invited and left rooms can be joined via this method + /// Only invited and left rooms can be joined via this method. #[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/docs/sync_running.md"))] pub(crate) async fn join(&self) -> Result { self.client.join_room_by_id(self.room_id()).await