From 5785d012a41d78825c3237a0e713dea033478881 Mon Sep 17 00:00:00 2001 From: torrybr <16907963+torrybr@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:06:46 -0400 Subject: [PATCH] chore(fmt): update formatting with fmt command --- bindings/matrix-sdk-ffi/src/timeline/mod.rs | 45 ++++++++++--------- crates/matrix-sdk-ui/src/timeline/beacons.rs | 6 ++- .../src/timeline/event_handler.rs | 15 ++++--- .../matrix-sdk-ui/src/timeline/inner/state.rs | 2 +- .../src/timeline/tests/beacons.rs | 3 +- crates/matrix-sdk/src/room/mod.rs | 4 +- 6 files changed, 43 insertions(+), 32 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index 6c85a61936b..d66fa3102bb 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -14,28 +14,18 @@ use std::{collections::HashMap, fmt::Write as _, fs, sync::Arc}; -use self::content::{Reaction, ReactionSenderData, TimelineItemContent}; -use crate::{ - client::ProgressWatcher, - error::{ClientError, RoomError}, - helpers::unwrap_or_clone_arc, - ruma::{ - AssetType, AudioInfo, FileInfo, FormattedBody, ImageInfo, PollKind, ThumbnailInfo, - VideoInfo, - }, - task_handle::TaskHandle, - RUNTIME, -}; use anyhow::{Context, Result}; use as_variant::as_variant; use content::{InReplyToDetails, RepliedToEventDetails}; use eyeball_im::VectorDiff; use futures_util::{pin_mut, StreamExt as _}; -use matrix_sdk::attachment::{ - AttachmentConfig, AttachmentInfo, BaseAudioInfo, BaseFileInfo, BaseImageInfo, - BaseThumbnailInfo, BaseVideoInfo, Thumbnail, +use matrix_sdk::{ + attachment::{ + AttachmentConfig, AttachmentInfo, BaseAudioInfo, BaseFileInfo, BaseImageInfo, + BaseThumbnailInfo, BaseVideoInfo, Thumbnail, + }, + deserialized_responses::SyncOrStrippedState, }; -use matrix_sdk::deserialized_responses::SyncOrStrippedState; use matrix_sdk_ui::timeline::{ EventItemOrigin, LiveBackPaginationStatus, Profile, RepliedToEvent, TimelineDetails, }; @@ -70,6 +60,19 @@ use tokio::{ use tracing::{error, info, warn}; use uuid::Uuid; +use self::content::{Reaction, ReactionSenderData, TimelineItemContent}; +use crate::{ + client::ProgressWatcher, + error::{ClientError, RoomError}, + helpers::unwrap_or_clone_arc, + ruma::{ + AssetType, AudioInfo, FileInfo, FormattedBody, ImageInfo, PollKind, ThumbnailInfo, + VideoInfo, + }, + task_handle::TaskHandle, + RUNTIME, +}; + mod content; #[derive(uniffi::Object)] @@ -523,11 +526,13 @@ impl Timeline { Ok(()) } - /// Sends a user's location as a beacon based on their last beacon_info event. + /// Sends a user's location as a beacon based on their last beacon_info + /// event. /// - /// Retrieves the last beacon_info from the room state and sends a beacon with the geo_uri. - /// Since only one active beacon_info per user per room is allowed, we can grab the currently live - /// beacon_info event from the room state. + /// Retrieves the last beacon_info from the room state and sends a beacon + /// with the geo_uri. Since only one active beacon_info per user per + /// room is allowed, we can grab the currently live beacon_info event + /// from the room state. /// /// TODO: Does the logic belong in self.inner.room() or here? pub async fn send_user_location_beacon( diff --git a/crates/matrix-sdk-ui/src/timeline/beacons.rs b/crates/matrix-sdk-ui/src/timeline/beacons.rs index 0cc5fd893b9..82c41d8dbd0 100644 --- a/crates/matrix-sdk-ui/src/timeline/beacons.rs +++ b/crates/matrix-sdk-ui/src/timeline/beacons.rs @@ -1,4 +1,5 @@ -//! This module handles rendering of MSC3489 live location sharing in the timeline. +//! This module handles rendering of MSC3489 live location sharing in the +//! timeline. use std::collections::HashMap; @@ -13,7 +14,8 @@ use ruma::{ /// Holds the state of a beacon_info. /// /// This struct should be created for each beacon_info event handled and then -/// updated whenever handling any beacon event that relates to the same beacon_info event. +/// updated whenever handling any beacon event that relates to the same +/// beacon_info event. #[derive(Clone, Debug)] pub struct BeaconState { pub(super) beacon_info_event_content: BeaconInfoEventContent, diff --git a/crates/matrix-sdk-ui/src/timeline/event_handler.rs b/crates/matrix-sdk-ui/src/timeline/event_handler.rs index 882ea947a77..487415709ba 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_handler.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_handler.rs @@ -63,8 +63,9 @@ use super::{ EventTimelineItem, InReplyToDetails, Message, OtherState, ReactionGroup, ReactionSenderData, Sticker, TimelineDetails, TimelineItem, TimelineItemContent, }; -use crate::timeline::beacons::BeaconState; -use crate::{events::SyncTimelineEventWithoutContent, DEFAULT_SANITIZER_MODE}; +use crate::{ + events::SyncTimelineEventWithoutContent, timeline::beacons::BeaconState, DEFAULT_SANITIZER_MODE, +}; /// When adding an event, useful information related to the source of the event. #[derive(Clone)] @@ -683,10 +684,11 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { /// Handle a beacon_info event and update the `BeaconInfoState`. /// - /// TODO: Handle case of `m.beacon_info` event that is identical to the first, except with live: false. - /// This stops the live location share. + /// TODO: Handle case of `m.beacon_info` event that is identical to the + /// first, except with live: false. This stops the live location share. /// - /// TODO: How do you search for an existing beacon_info event in the timeline by state key? + /// TODO: How do you search for an existing beacon_info event in the + /// timeline by state key? fn handle_beacon_info( &mut self, c: FullStateEventContent, @@ -705,7 +707,8 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { } } - /// Attach the last known beacon location to the `BeaconInfoState` for a specific beacon_info. + /// Attach the last known beacon location to the `BeaconInfoState` for a + /// specific beacon_info. /// /// A beacon may arrive before its beacon_info event, so we store the beacon /// in a pending list until the beacon_info event arrives. diff --git a/crates/matrix-sdk-ui/src/timeline/inner/state.rs b/crates/matrix-sdk-ui/src/timeline/inner/state.rs index 75e60e43aa1..4cfa4c62c3a 100644 --- a/crates/matrix-sdk-ui/src/timeline/inner/state.rs +++ b/crates/matrix-sdk-ui/src/timeline/inner/state.rs @@ -30,10 +30,10 @@ use ruma::{ use tracing::{debug, error, instrument, trace, warn}; use super::{HandleManyEventsResult, ReactionState, TimelineInnerSettings}; -use crate::timeline::beacons::BeaconPendingEvents; use crate::{ events::SyncTimelineEventWithoutContent, timeline::{ + beacons::BeaconPendingEvents, day_dividers::DayDividerAdjuster, event_handler::{ Flow, HandleEventResult, TimelineEventContext, TimelineEventHandler, TimelineEventKind, diff --git a/crates/matrix-sdk-ui/src/timeline/tests/beacons.rs b/crates/matrix-sdk-ui/src/timeline/tests/beacons.rs index db6897ee8c1..52c77a62c40 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/beacons.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/beacons.rs @@ -279,9 +279,10 @@ impl EventTimelineItem { } mod fakes { - use ruma::events::beacon_info::BeaconInfoEventContent; use std::time::Duration; + use ruma::events::beacon_info::BeaconInfoEventContent; + pub fn create_beacon_info(desc: &str, duration: u64) -> BeaconInfoEventContent { BeaconInfoEventContent::new( Option::from(desc.to_string()), diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index ad87e871186..cd2430adc79 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -2519,8 +2519,8 @@ impl Room { /// Send a beacon_info state event to stop an existing live location share. /// - /// Find existing beacon_info by state key and set the `live` field to `false` in the - /// existing beacon_info event. + /// Find existing beacon_info by state key and set the `live` field to + /// `false` in the existing beacon_info event. /// /// TODO: Update the return type to be specific. pub async fn stop_beacon_info(&self) -> Result {