Skip to content

chore(ui): Make TimelineInnerMetadata::next_internal_id private #3526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading