chore(ui): Make TimelineInnerMetadata::next_internal_id private.

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.
This commit is contained in:
Ivan Enderlin
2024-06-05 16:43:43 +02:00
parent e5487da160
commit 2a70587dda
2 changed files with 5 additions and 7 deletions

View File

@@ -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);

View File

@@ -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("");