mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-06 06:53:32 -04:00
fix(sdk): Fix day divider removal logic in timeline
This commit is contained in:
committed by
Jonas Platte
parent
e8d5d29d2c
commit
38e2d0bdcd
@@ -700,12 +700,12 @@ impl<'a, 'i> TimelineEventHandler<'a, 'i> {
|
||||
// Pre-requisites for removing the day divider:
|
||||
// 1. there is one preceding the old item at all
|
||||
if self.timeline_items[idx - 1].is_day_divider()
|
||||
// 2. the next item after the old one being removed
|
||||
// 2. the item after the old one that was removed
|
||||
// is virtual (it should be impossible for this
|
||||
// to be a read marker)
|
||||
&& self
|
||||
.timeline_items
|
||||
.get(idx + 1)
|
||||
.get(idx)
|
||||
.map_or(true, |item| item.is_virtual())
|
||||
{
|
||||
trace!("Removing day divider");
|
||||
|
||||
@@ -136,8 +136,11 @@ async fn remote_echo_new_position() {
|
||||
|
||||
// … the local echo should be removed
|
||||
assert_matches!(stream.next().await, Some(VecDiff::RemoveAt { index: 1 }));
|
||||
// … along with its day divider
|
||||
assert_matches!(stream.next().await, Some(VecDiff::RemoveAt { index: 0 }));
|
||||
|
||||
// … and the remote echo added
|
||||
// … and the remote echo added (no new day divider because both bob's and
|
||||
// alice's message are from the same day according to server timestamps)
|
||||
let item = assert_matches!(stream.next().await, Some(VecDiff::Push { value }) => value);
|
||||
assert_matches!(item.as_event().unwrap(), EventTimelineItem::Remote(_));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user