diff --git a/crates/matrix-sdk-ui/src/timeline/controller/state.rs b/crates/matrix-sdk-ui/src/timeline/controller/state.rs index 4204481b9f4..fd543556fa9 100644 --- a/crates/matrix-sdk-ui/src/timeline/controller/state.rs +++ b/crates/matrix-sdk-ui/src/timeline/controller/state.rs @@ -251,7 +251,7 @@ impl TimelineState { let handle_one_res = txn .handle_remote_event( event.into(), - TimelineItemPosition::UpdateDecrypted(idx), + TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx }, room_data_provider, settings, &mut day_divider_adjuster, @@ -451,7 +451,7 @@ impl TimelineStateTransaction<'_> { TimelineItemPosition::End { origin } | TimelineItemPosition::Start { origin } => origin, - TimelineItemPosition::UpdateDecrypted(idx) => self + TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx } => self .items .get(idx) .and_then(|item| item.as_event()) @@ -707,7 +707,7 @@ impl TimelineStateTransaction<'_> { self.meta.all_events.push_back(event_meta.base_meta()); } - TimelineItemPosition::UpdateDecrypted(_) => { + 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 941823b967a..aad559c0469 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_handler.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_handler.rs @@ -269,17 +269,26 @@ impl TimelineEventKind { pub(super) enum TimelineItemPosition { /// One or more items are prepended to the timeline (i.e. they're the /// oldest). - Start { origin: RemoteEventOrigin }, + Start { + /// The origin of the new item(s). + origin: RemoteEventOrigin, + }, /// One or more items are appended to the timeline (i.e. they're the most /// recent). - End { origin: RemoteEventOrigin }, + End { + /// The origin of the new item(s). + origin: RemoteEventOrigin, + }, /// A single item is updated, after it's been successfully decrypted. /// /// This happens when an item that was a UTD must be replaced with the /// decrypted event. - UpdateDecrypted(usize), + UpdateDecrypted { + /// The index of the **timeline item**. + timeline_item_index: usize, + }, } /// The outcome of handling a single event with @@ -481,8 +490,10 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { if !self.result.item_added { trace!("No new item added"); - if let Flow::Remote { position: TimelineItemPosition::UpdateDecrypted(idx), .. } = - self.ctx.flow + if let Flow::Remote { + position: TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx }, + .. + } = self.ctx.flow { // If add was not called, that means the UTD event is one that // wouldn't normally be visible. Remove it. @@ -576,7 +587,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { replacement: PendingEdit, ) { match position { - TimelineItemPosition::Start { .. } | TimelineItemPosition::UpdateDecrypted(_) => { + TimelineItemPosition::Start { .. } | TimelineItemPosition::UpdateDecrypted { .. } => { // Only insert the edit if there wasn't any other edit // before. // @@ -1012,7 +1023,8 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { | TimelineItemPosition::End { origin } => origin, // For updates, reuse the origin of the encrypted event. - TimelineItemPosition::UpdateDecrypted(idx) => self.items[idx] + TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx } => self + .items[idx] .as_event() .and_then(|ev| Some(ev.as_remote()?.origin)) .unwrap_or_else(|| { @@ -1162,7 +1174,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { Flow::Remote { event_id: decrypted_event_id, - position: TimelineItemPosition::UpdateDecrypted(idx), + position: TimelineItemPosition::UpdateDecrypted { timeline_item_index: idx }, .. } => { trace!("Updating timeline item at position {idx}");