Skip to content

Commit

Permalink
timeline: flatten ReactionSenderData into ReactionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Jul 25, 2024
1 parent f61cc92 commit 8a8a581
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
16 changes: 6 additions & 10 deletions crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ use super::{
polls::PollState,
reactions::FullReactionKey,
util::{rfind_event_by_id, rfind_event_item},
EventTimelineItem, InReplyToDetails, Message, OtherState, ReactionSenderData, Sticker,
TimelineDetails, TimelineItem, TimelineItemContent,
EventTimelineItem, InReplyToDetails, Message, OtherState, Sticker, TimelineDetails,
TimelineItem, TimelineItemContent,
};
use crate::{
events::SyncTimelineEventWithoutContent,
Expand Down Expand Up @@ -549,11 +549,6 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
}
};

let reaction_sender_data = ReactionSenderData {
sender_id: self.ctx.sender.clone(),
timestamp: self.ctx.timestamp,
};

if let Some((idx, event_item)) = rfind_event_by_id(self.items, reacted_to_event_id) {
let Some(remote_event_item) = event_item.as_remote() else {
error!("received reaction to a local echo");
Expand Down Expand Up @@ -591,7 +586,8 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
reaction_event_id,
PendingReaction {
key: c.relates_to.key.clone(),
sender_data: reaction_sender_data.clone(),
sender_id: self.ctx.sender.clone(),
timestamp: self.ctx.timestamp,
},
);
}
Expand Down Expand Up @@ -1035,9 +1031,9 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
bundled.entry(reaction.key).or_default();

group.insert(
reaction.sender_data.sender_id,
reaction.sender_id,
ReactionInfo {
timestamp: reaction.sender_data.timestamp,
timestamp: reaction.timestamp,
id: TimelineEventItemId::EventId(reaction_event_id),
},
);
Expand Down
1 change: 0 additions & 1 deletion crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ pub use self::{
item::{TimelineItem, TimelineItemKind},
pagination::LiveBackPaginationStatus,
polls::PollResult,
reactions::ReactionSenderData,
traits::RoomExt,
virtual_item::VirtualTimelineItem,
};
Expand Down
15 changes: 4 additions & 11 deletions crates/matrix-sdk-ui/src/timeline/reactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,16 @@ pub(super) enum ReactionState {
Sending(OwnedTransactionId),
}

/// Data associated with a reaction sender. It can be used to display
/// a details UI component for a reaction with both sender
/// names and the date at which they sent a reaction.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct ReactionSenderData {
#[derive(Clone, Debug)]
pub(crate) struct PendingReaction {
/// The annotation used for the reaction.
pub key: String,
/// Sender identifier.
pub sender_id: OwnedUserId,
/// Date at which the sender reacted.
pub timestamp: MilliSecondsSinceUnixEpoch,
}

#[derive(Clone, Debug)]
pub(crate) struct PendingReaction {
pub key: String,
pub sender_data: ReactionSenderData,
}

#[derive(Clone, Debug)]
pub(crate) struct FullReactionKey {
pub item: TimelineEventItemId,
Expand Down

0 comments on commit 8a8a581

Please sign in to comment.