fix(sdk): Fix day divider removal logic in timeline

This commit is contained in:
Jonas Platte
2023-02-15 16:15:16 +01:00
committed by Jonas Platte
parent e8d5d29d2c
commit 38e2d0bdcd
2 changed files with 6 additions and 3 deletions

View File

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

View File

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