mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 21:52:30 -04:00
refactor(timeline): use TimelineEventKind::HandleAggregation for edits
This commit is contained in:
@@ -137,6 +137,8 @@ pub(super) enum HandleAggregationKind {
|
||||
Reaction { key: String },
|
||||
|
||||
Redaction,
|
||||
|
||||
Edit { replacement: Replacement<RoomMessageEventContentWithoutRelation> },
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -251,6 +253,14 @@ impl TimelineEventKind {
|
||||
}
|
||||
}
|
||||
|
||||
AnyMessageLikeEventContent::RoomMessage(RoomMessageEventContent {
|
||||
relates_to: Some(Relation::Replacement(re)),
|
||||
..
|
||||
}) => Self::HandleAggregation {
|
||||
related_event: re.event_id.clone(),
|
||||
kind: HandleAggregationKind::Edit { replacement: re },
|
||||
},
|
||||
|
||||
_ => {
|
||||
// Default path: TODO remove
|
||||
Self::Message { content, relations: ev.relations() }
|
||||
@@ -448,16 +458,12 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
|
||||
HandleAggregationKind::Redaction => {
|
||||
self.handle_redaction(related_event);
|
||||
}
|
||||
HandleAggregationKind::Edit { replacement } => {
|
||||
self.handle_room_message_edit(replacement);
|
||||
}
|
||||
},
|
||||
|
||||
TimelineEventKind::Message { content, relations } => match content {
|
||||
AnyMessageLikeEventContent::RoomMessage(RoomMessageEventContent {
|
||||
relates_to: Some(Relation::Replacement(re)),
|
||||
..
|
||||
}) => {
|
||||
self.handle_room_message_edit(re);
|
||||
}
|
||||
|
||||
AnyMessageLikeEventContent::RoomMessage(c) => {
|
||||
if should_add {
|
||||
self.handle_room_message(c, relations);
|
||||
|
||||
Reference in New Issue
Block a user