Skip to content

Commit 76133ef

Browse files
committed
refactor(timeline): simplify removal of duplicated local echo item
1 parent 3341260 commit 76133ef

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

crates/matrix-sdk-ui/src/timeline/event_handler.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
10741074
let removed_duplicated_timeline_item = Self::deduplicate_local_timeline_item(
10751075
self.items,
10761076
&mut item,
1077-
Some(event_id),
1077+
event_id,
10781078
txn_id.as_ref().map(AsRef::as_ref),
10791079
);
10801080
let item = new_timeline_item(self.meta, item, removed_duplicated_timeline_item);
@@ -1093,7 +1093,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
10931093
let removed_duplicated_timeline_item = Self::deduplicate_local_timeline_item(
10941094
self.items,
10951095
&mut item,
1096-
Some(event_id),
1096+
event_id,
10971097
txn_id.as_ref().map(AsRef::as_ref),
10981098
);
10991099
let item = new_timeline_item(self.meta, item, removed_duplicated_timeline_item);
@@ -1156,7 +1156,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
11561156
let removed_duplicated_timeline_item = Self::deduplicate_local_timeline_item(
11571157
self.items,
11581158
&mut item,
1159-
Some(event_id),
1159+
event_id,
11601160
txn_id.as_ref().map(AsRef::as_ref),
11611161
);
11621162
let item = new_timeline_item(self.meta, item, removed_duplicated_timeline_item);
@@ -1235,11 +1235,10 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
12351235
/// `transaction_id` of `new_event_timeline_item` if it exists.
12361236
// Note: this method doesn't take `&mut self` to avoid a borrow checker
12371237
// conflict with `TimelineEventHandler::add_item`.
1238-
// TODO(bnjbvr): refactor
12391238
fn deduplicate_local_timeline_item(
12401239
items: &mut ObservableItemsTransaction<'_>,
12411240
new_event_timeline_item: &mut EventTimelineItem,
1242-
event_id: Option<&EventId>,
1241+
event_id: &EventId,
12431242
transaction_id: Option<&TransactionId>,
12441243
) -> Option<Arc<TimelineItem>> {
12451244
// Detect a local timeline item that matches `event_id` or `transaction_id`.
@@ -1270,7 +1269,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
12701269
return ControlFlow::Break(None);
12711270
}
12721271

1273-
if event_id == event_timeline_item.event_id()
1272+
if Some(event_id) == event_timeline_item.event_id()
12741273
|| (transaction_id.is_some()
12751274
&& transaction_id == event_timeline_item.transaction_id())
12761275
{

0 commit comments

Comments
 (0)