Skip to content

Commit

Permalink
chore(ui): Make TimelineInnerMetadata::next_internal_id private.
Browse files Browse the repository at this point in the history
This patch updates `TimelineEventHandler` to re-use the public API and
avoid using `TimelineInnerMeta::next_internal_id`. The consequence is
that `next_internal_id` can now be private instead of public. It's
better to have isolated API in this code.
  • Loading branch information
Hywan committed Jun 10, 2024
1 parent e5487da commit 2a70587
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,17 +1005,15 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
// pending local echo, or at the start if there is no such item.
let insert_idx = latest_event_idx.map_or(0, |idx| idx + 1);

let id = match removed_event_item_id {
trace!("Adding new remote timeline item after all non-pending events");
let new_item = match removed_event_item_id {
// If a previous version of the same item (usually a local
// echo) was removed and we now need to add it again, reuse
// the previous item's ID.
Some(id) => id,
None => self.meta.next_internal_id(),
Some(id) => TimelineItem::new(item, id),
None => self.meta.new_timeline_item(item),
};

trace!("Adding new remote timeline item after all non-pending events");
let new_item = TimelineItem::new(item, id);

// Keep push semantics, if we're inserting at the front or the back.
if insert_idx == self.items.len() {
self.items.push_back(new_item);
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/timeline/inner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ impl TimelineInnerMetadata {

/// Returns the next internal id for a timeline item (and increment our
/// internal counter).
pub fn next_internal_id(&mut self) -> String {
fn next_internal_id(&mut self) -> String {
let val = self.next_internal_id;
self.next_internal_id += 1;
let prefix = self.internal_id_prefix.as_deref().unwrap_or("");
Expand Down

0 comments on commit 2a70587

Please sign in to comment.