Skip to content

Commit

Permalink
chore(ui): Rename TimelineInnerState::add_event to `add_or_update_e…
Browse files Browse the repository at this point in the history
…vent`.

This patch renames `add_event` to `add_or_update_event` because it is
what it does.
  • Loading branch information
Hywan committed Jun 13, 2024
1 parent 15ed91e commit d46e658
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions crates/matrix-sdk-ui/src/timeline/inner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,9 @@ impl TimelineInnerStateTransaction<'_> {
timestamp: Some(event.origin_server_ts()),
visible: false,
};
let _event_added =
self.add_event(event_meta, position, room_data_provider, settings).await;
let _event_added_or_updated = self
.add_or_update_event(event_meta, position, room_data_provider, settings)
.await;

return HandleEventResult::default();
}
Expand All @@ -527,8 +528,8 @@ impl TimelineInnerStateTransaction<'_> {
timestamp,
visible: false,
};
let _event_added = self
.add_event(event_meta, position, room_data_provider, settings)
let _event_added_or_updated = self
.add_or_update_event(event_meta, position, room_data_provider, settings)
.await;
}

Expand All @@ -547,11 +548,12 @@ impl TimelineInnerStateTransaction<'_> {
visible: should_add,
};

let event_added = self.add_event(event_meta, position, room_data_provider, settings).await;
let event_added_or_updated =
self.add_or_update_event(event_meta, position, room_data_provider, settings).await;

// If the event has not been added, it's because it's a duplicated event. Let's
// return early.
if !event_added {
// If the event has not been added or updated, it's because it's a duplicated
// event. Let's return early.
if !event_added_or_updated {
return HandleEventResult::default();
}

Expand Down Expand Up @@ -647,14 +649,15 @@ impl TimelineInnerStateTransaction<'_> {
items.commit();
}

/// Add an event in the [`TimelineInnerMeta::all_events`] collection.
/// Add or update an event in the [`TimelineInnerMeta::all_events`]
/// collection.
///
/// This method also adjusts read receipt if needed.
///
/// It returns `true` if the event has been added, `false` otherwise. The
/// latter happens if the event already exists, i.e. if an existing event is
/// requested to be added.
async fn add_event<P: RoomDataProvider>(
/// It returns `true` if the event has been added or updated, `false`
/// otherwise. The latter happens if the event already exists, i.e. if
/// an existing event is requested to be added.
async fn add_or_update_event<P: RoomDataProvider>(
&mut self,
event_meta: FullEventMeta<'_>,
position: TimelineItemPosition,
Expand Down

0 comments on commit d46e658

Please sign in to comment.