Skip to content

Commit

Permalink
chore(fmt): update formatting with fmt command
Browse files Browse the repository at this point in the history
  • Loading branch information
torrybr committed Jul 1, 2024
1 parent e453555 commit 5785d01
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 32 deletions.
45 changes: 25 additions & 20 deletions bindings/matrix-sdk-ffi/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/beacons.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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,
Expand Down
15 changes: 9 additions & 6 deletions crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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<BeaconInfoEventContent>,
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/timeline/inner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion crates/matrix-sdk-ui/src/timeline/tests/beacons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<send_state_event::v3::Response> {
Expand Down

0 comments on commit 5785d01

Please sign in to comment.