Browse Source

misc: Fix new clippy warnings

fractal-12
Kévin Commaille 10 months ago
parent
commit
6035b4ee37
No known key found for this signature in database
GPG Key ID: F26F4BE20A08255B
  1. 8
      src/session/view/content/room_history/message_toolbar/composer_state.rs
  2. 2
      src/session/view/content/room_history/message_toolbar/mod.rs
  3. 16
      src/utils/matrix/media_message.rs
  4. 20
      src/utils/matrix/mod.rs

8
src/session/view/content/room_history/message_toolbar/composer_state.rs

@ -517,7 +517,7 @@ impl ComposerState {
#[derive(Debug, Clone)]
pub(crate) enum RelationInfo {
/// Send a reply to the given event.
Reply(MessageEventSource),
Reply(Box<MessageEventSource>),
/// Send an edit to the event with the given ID.
Edit(OwnedEventId),
@ -551,7 +551,7 @@ impl RelationInfo {
return None;
};
Some(RelationInfo::Reply(message_event))
Some(RelationInfo::Reply(message_event.into()))
}
ComposerDraftType::Edit { event_id } => Some(RelationInfo::Edit(event_id)),
}
@ -648,7 +648,7 @@ struct DetectedMention {
#[derive(Debug, Clone)]
pub(crate) enum MessageEventSource {
/// An original event.
OriginalEvent(OriginalSyncRoomMessageEvent),
OriginalEvent(Box<OriginalSyncRoomMessageEvent>),
/// An [`Event`].
Event(Event),
}
@ -663,7 +663,7 @@ impl MessageEventSource {
match event {
AnySyncTimelineEvent::MessageLike(AnySyncMessageLikeEvent::RoomMessage(
SyncMessageLikeEvent::Original(message_event),
)) => Some(Self::OriginalEvent(message_event)),
)) => Some(Self::OriginalEvent(message_event.into())),
_ => None,
}
}

2
src/session/view/content/room_history/message_toolbar/mod.rs

@ -573,7 +573,7 @@ mod imp {
};
self.current_composer_state()
.set_related_to(Some(RelationInfo::Reply(message_event)));
.set_related_to(Some(RelationInfo::Reply(message_event.into())));
self.message_entry.grab_focus();
}

16
src/utils/matrix/media_message.rs

@ -56,7 +56,7 @@ pub(crate) enum MediaMessage {
/// A video.
Video(VideoMessageEventContent),
/// A sticker.
Sticker(StickerEventContent),
Sticker(Box<StickerEventContent>),
}
impl MediaMessage {
@ -104,7 +104,7 @@ impl MediaMessage {
let media = client.media();
macro_rules! content {
($event_content:ident) => {{
($event_content:expr) => {{
Ok(
$crate::spawn_tokio!(
async move { media.get_file(&$event_content, true).await }
@ -121,7 +121,7 @@ impl MediaMessage {
Self::File(c) => content!(c),
Self::Image(c) => content!(c),
Self::Video(c) => content!(c),
Self::Sticker(c) => content!(c),
Self::Sticker(c) => content!(*c),
}
}
@ -199,7 +199,7 @@ impl From<FileMessageEventContent> for MediaMessage {
impl From<StickerEventContent> for MediaMessage {
fn from(value: StickerEventContent) -> Self {
Self::Sticker(value)
Self::Sticker(value.into())
}
}
@ -211,7 +211,7 @@ pub(crate) enum VisualMediaMessage {
/// A video.
Video(VideoMessageEventContent),
/// A sticker.
Sticker(StickerEventContent),
Sticker(Box<StickerEventContent>),
}
impl VisualMediaMessage {
@ -373,6 +373,12 @@ impl From<VideoMessageEventContent> for VisualMediaMessage {
impl From<StickerEventContent> for VisualMediaMessage {
fn from(value: StickerEventContent) -> Self {
Self::Sticker(value.into())
}
}
impl From<Box<StickerEventContent>> for VisualMediaMessage {
fn from(value: Box<StickerEventContent>) -> Self {
Self::Sticker(value)
}
}

20
src/utils/matrix/mod.rs

@ -113,9 +113,9 @@ pub(crate) fn validate_password(password: &str) -> PasswordValidity {
#[derive(Debug, Clone)]
pub(crate) enum AnySyncOrStrippedTimelineEvent {
/// An event from a joined or left room.
Sync(AnySyncTimelineEvent),
Sync(Box<AnySyncTimelineEvent>),
/// An event from an invited room.
Stripped(AnyStrippedStateEvent),
Stripped(Box<AnyStrippedStateEvent>),
}
impl AnySyncOrStrippedTimelineEvent {
@ -124,8 +124,10 @@ impl AnySyncOrStrippedTimelineEvent {
raw: &RawAnySyncOrStrippedTimelineEvent,
) -> Result<Self, serde_json::Error> {
let ev = match raw {
RawAnySyncOrStrippedTimelineEvent::Sync(ev) => Self::Sync(ev.deserialize()?),
RawAnySyncOrStrippedTimelineEvent::Stripped(ev) => Self::Stripped(ev.deserialize()?),
RawAnySyncOrStrippedTimelineEvent::Sync(ev) => Self::Sync(ev.deserialize()?.into()),
RawAnySyncOrStrippedTimelineEvent::Stripped(ev) => {
Self::Stripped(ev.deserialize()?.into())
}
};
Ok(ev)
@ -161,10 +163,12 @@ pub(crate) fn get_event_body(
show_sender: bool,
) -> Option<String> {
match event {
AnySyncOrStrippedTimelineEvent::Sync(AnySyncTimelineEvent::MessageLike(message)) => {
get_message_event_body(message, sender_name, show_sender)
}
AnySyncOrStrippedTimelineEvent::Sync(_) => None,
AnySyncOrStrippedTimelineEvent::Sync(sync_event) => match &**sync_event {
AnySyncTimelineEvent::MessageLike(message) => {
get_message_event_body(message, sender_name, show_sender)
}
AnySyncTimelineEvent::State(_) => None,
},
AnySyncOrStrippedTimelineEvent::Stripped(state) => {
get_stripped_state_event_body(state, sender_name, own_user)
}

Loading…
Cancel
Save