From 4c0819410721848ed2089928d04c2fde9eb10eb1 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 15 Jan 2025 18:17:36 +0100 Subject: [PATCH] refactor(timeline): rename `TimelineItemPosition::UpdateDecrypted` to `UpdateAt` --- .../src/timeline/controller/state.rs | 8 ++++---- .../matrix-sdk-ui/src/timeline/event_handler.rs | 17 ++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/crates/matrix-sdk-ui/src/timeline/controller/state.rs b/crates/matrix-sdk-ui/src/timeline/controller/state.rs index f8e5cb8228..5763f990d2 100644 --- a/crates/matrix-sdk-ui/src/timeline/controller/state.rs +++ b/crates/matrix-sdk-ui/src/timeline/controller/state.rs @@ -281,7 +281,7 @@ impl TimelineState { let handle_one_res = txn .handle_remote_event( event.into(), - TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx }, + TimelineItemPosition::UpdateAt { timeline_item_index: idx }, room_data_provider, settings, &mut date_divider_adjuster, @@ -506,7 +506,7 @@ impl TimelineStateTransaction<'_> { { self.handle_remote_event( event, - TimelineItemPosition::UpdateDecrypted { timeline_item_index }, + TimelineItemPosition::UpdateAt { timeline_item_index }, room_data_provider, settings, &mut date_divider_adjuster, @@ -592,7 +592,7 @@ impl TimelineStateTransaction<'_> { | TimelineItemPosition::Start { origin } | TimelineItemPosition::At { origin, .. } => origin, - TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx } => self + TimelineItemPosition::UpdateAt { timeline_item_index: idx } => self .items .get(idx) .and_then(|item| item.as_event()) @@ -876,7 +876,7 @@ impl TimelineStateTransaction<'_> { self.items.insert_remote_event(event_index, event_meta.base_meta()); } - TimelineItemPosition::UpdateDecrypted { .. } => { + TimelineItemPosition::UpdateAt { .. } => { if let Some(event) = self.items.get_remote_event_by_event_id_mut(event_meta.event_id) { diff --git a/crates/matrix-sdk-ui/src/timeline/event_handler.rs b/crates/matrix-sdk-ui/src/timeline/event_handler.rs index b3288ca299..f9d286b45d 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_handler.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_handler.rs @@ -300,11 +300,11 @@ pub(super) enum TimelineItemPosition { origin: RemoteEventOrigin, }, - /// A single item is updated, after it's been successfully decrypted. + /// A single item is updated. /// - /// This happens when an item that was a UTD must be replaced with the - /// decrypted event. - UpdateDecrypted { + /// This can happen for instance after a UTD has been successfully + /// decrypted, or when it's been redacted at the source. + UpdateAt { /// The index of the **timeline item**. timeline_item_index: usize, }, @@ -511,7 +511,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { trace!("No new item added"); if let Flow::Remote { - position: TimelineItemPosition::UpdateDecrypted { timeline_item_index }, + position: TimelineItemPosition::UpdateAt { timeline_item_index }, .. } = self.ctx.flow { @@ -609,7 +609,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { match position { TimelineItemPosition::Start { .. } | TimelineItemPosition::At { .. } - | TimelineItemPosition::UpdateDecrypted { .. } => { + | TimelineItemPosition::UpdateAt { .. } => { // Only insert the edit if there wasn't any other edit // before. // @@ -1057,8 +1057,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { | TimelineItemPosition::At { origin, .. } => origin, // For updates, reuse the origin of the encrypted event. - TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx } => self - .items[idx] + TimelineItemPosition::UpdateAt { timeline_item_index: idx } => self.items[idx] .as_event() .and_then(|ev| Some(ev.as_remote()?.origin)) .unwrap_or_else(|| { @@ -1241,7 +1240,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { Flow::Remote { event_id: decrypted_event_id, - position: TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx }, + position: TimelineItemPosition::UpdateAt { timeline_item_index: idx }, .. } => { trace!("Updating timeline item at position {idx}");