Skip to content

Commit

Permalink
refactor(timeline): rename TimelineItemPosition::UpdateDecrypted to…
Browse files Browse the repository at this point in the history
… `UpdateAt`
  • Loading branch information
bnjbvr committed Jan 16, 2025
1 parent 5038309 commit 7fa06cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/controller/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
{
Expand Down
17 changes: 8 additions & 9 deletions crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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(|| {
Expand Down Expand Up @@ -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}");
Expand Down

0 comments on commit 7fa06cb

Please sign in to comment.