From b233aa64d297d61218e2fb19e89125a0b62c36fa Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Tue, 5 Nov 2024 14:43:40 +0100 Subject: [PATCH] chore(timeline): rename `TimelineItemPosition::Update` to `UpdateDecrypted` --- .../src/timeline/controller/state.rs | 6 +++--- .../matrix-sdk-ui/src/timeline/event_handler.rs | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/matrix-sdk-ui/src/timeline/controller/state.rs b/crates/matrix-sdk-ui/src/timeline/controller/state.rs index b30102525fb..3668622dacd 100644 --- a/crates/matrix-sdk-ui/src/timeline/controller/state.rs +++ b/crates/matrix-sdk-ui/src/timeline/controller/state.rs @@ -241,7 +241,7 @@ impl TimelineState { let handle_one_res = txn .handle_remote_event( event.into(), - TimelineItemPosition::Update(idx), + TimelineItemPosition::UpdateDecrypted(idx), room_data_provider, settings, &mut day_divider_adjuster, @@ -447,7 +447,7 @@ impl TimelineStateTransaction<'_> { TimelineItemPosition::End { origin } | TimelineItemPosition::Start { origin } => origin, - TimelineItemPosition::Update(idx) => self + TimelineItemPosition::UpdateDecrypted(idx) => self .items .get(idx) .and_then(|item| item.as_event()) @@ -703,7 +703,7 @@ impl TimelineStateTransaction<'_> { self.meta.all_events.push_back(event_meta.base_meta()); } - TimelineItemPosition::Update(_) => { + TimelineItemPosition::UpdateDecrypted(_) => { if let Some(event) = self.meta.all_events.iter_mut().find(|e| e.event_id == 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 20358cae735..941823b967a 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_handler.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_handler.rs @@ -275,10 +275,11 @@ pub(super) enum TimelineItemPosition { /// recent). End { origin: RemoteEventOrigin }, - /// A single item is updated. + /// A single item is updated, after it's been successfully decrypted. /// - /// This only happens when a UTD must be replaced with the decrypted event. - Update(usize), + /// This happens when an item that was a UTD must be replaced with the + /// decrypted event. + UpdateDecrypted(usize), } /// The outcome of handling a single event with @@ -480,7 +481,8 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { if !self.result.item_added { trace!("No new item added"); - if let Flow::Remote { position: TimelineItemPosition::Update(idx), .. } = self.ctx.flow + if let Flow::Remote { position: TimelineItemPosition::UpdateDecrypted(idx), .. } = + self.ctx.flow { // If add was not called, that means the UTD event is one that // wouldn't normally be visible. Remove it. @@ -574,7 +576,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { replacement: PendingEdit, ) { match position { - TimelineItemPosition::Start { .. } | TimelineItemPosition::Update(_) => { + TimelineItemPosition::Start { .. } | TimelineItemPosition::UpdateDecrypted(_) => { // Only insert the edit if there wasn't any other edit // before. // @@ -1010,7 +1012,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { | TimelineItemPosition::End { origin } => origin, // For updates, reuse the origin of the encrypted event. - TimelineItemPosition::Update(idx) => self.items[idx] + TimelineItemPosition::UpdateDecrypted(idx) => self.items[idx] .as_event() .and_then(|ev| Some(ev.as_remote()?.origin)) .unwrap_or_else(|| { @@ -1160,7 +1162,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { Flow::Remote { event_id: decrypted_event_id, - position: TimelineItemPosition::Update(idx), + position: TimelineItemPosition::UpdateDecrypted(idx), .. } => { trace!("Updating timeline item at position {idx}");