Skip to content

Commit be86fe4

Browse files
committed
doc: Improve doc comments
Also move `EventMeta::thread_root_id` next to `event_id`
1 parent 385f7aa commit be86fe4

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

crates/matrix-sdk-ui/src/timeline/controller/metadata.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,10 @@ pub(in crate::timeline) struct EventMeta {
512512
/// The ID of the event.
513513
pub event_id: OwnedEventId,
514514

515+
/// If this event is part of a thread, this will contain its thread root
516+
/// event id.
517+
pub thread_root_id: Option<OwnedEventId>,
518+
515519
/// Whether the event is among the timeline items.
516520
pub visible: bool,
517521

@@ -577,8 +581,6 @@ pub(in crate::timeline) struct EventMeta {
577581
/// Note that the #2 timeline item (the day divider) doesn't map to any
578582
/// remote event, but if it moves, it has an impact on this mapping.
579583
pub timeline_item_index: Option<usize>,
580-
581-
pub thread_root_id: Option<OwnedEventId>,
582584
}
583585

584586
impl EventMeta {
@@ -587,6 +589,6 @@ impl EventMeta {
587589
visible: bool,
588590
thread_root_id: Option<OwnedEventId>,
589591
) -> Self {
590-
Self { event_id, visible, timeline_item_index: None, thread_root_id }
592+
Self { event_id, thread_root_id, visible, timeline_item_index: None }
591593
}
592594
}

crates/matrix-sdk-ui/src/timeline/controller/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,11 @@ impl TimelineController {
17691769
}
17701770
_ => true,
17711771
};
1772+
1773+
// In some timelines, threaded events are added to the `AllRemoteEvents`
1774+
// collection since they need to be taken into account to calculate read
1775+
// receipts, but we don't want to actually take them into account for returning
1776+
// the latest event id since they're not visibly in the timeline
17721777
state
17731778
.items
17741779
.all_remote_events()

crates/matrix-sdk-ui/src/timeline/controller/observable_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,9 @@ mod observable_items_tests {
798798
fn event_meta(event_id: &str) -> EventMeta {
799799
EventMeta {
800800
event_id: event_id.parse().unwrap(),
801+
thread_root_id: None,
801802
timeline_item_index: None,
802803
visible: false,
803-
thread_root_id: None,
804804
}
805805
}
806806

@@ -2062,9 +2062,9 @@ mod all_remote_events_tests {
20622062
fn event_meta(event_id: &str, timeline_item_index: Option<usize>) -> EventMeta {
20632063
EventMeta {
20642064
event_id: event_id.parse().unwrap(),
2065+
thread_root_id: None,
20652066
timeline_item_index,
20662067
visible: false,
2067-
thread_root_id: None,
20682068
}
20692069
}
20702070

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl Timeline {
268268
}
269269
}
270270

271-
/// Get the latest of the timeline's event ids.
271+
/// Get the latest of the timeline's remote event ids.
272272
pub async fn latest_event_id(&self) -> Option<OwnedEventId> {
273273
self.controller.latest_event_id().await
274274
}

0 commit comments

Comments
 (0)