Skip to content

Commit

Permalink
chore(timeline): rename TimelineItemPosition::Update to `UpdateDecr…
Browse files Browse the repository at this point in the history
…ypted`
  • Loading branch information
bnjbvr committed Nov 5, 2024
1 parent 90d6a37 commit 0619e86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions crates/matrix-sdk-ui/src/timeline/controller/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
{
Expand Down
16 changes: 9 additions & 7 deletions crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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(|| {
Expand Down Expand Up @@ -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}");
Expand Down

0 comments on commit 0619e86

Please sign in to comment.