Skip to content

fix(ui): Introduce Timeline regions #5000

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
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c012d12
fix(ui): Offset the timeline index in the presence of a `TimelineStart`.
Hywan May 5, 2025
b3ca0a4
test: Add assert messages in the `assert_timeline_stream` macro.
Hywan May 5, 2025
cfc50dc
test(ui): Support `index [$nth] --- date divider ---` in `assert_time…
Hywan May 6, 2025
3871ddf
test(ui): Add a regression test.
Hywan May 6, 2025
d30dfec
refactor(ui): Add `ObservableItemsTransaction::push_timeline_start_if…
Hywan May 6, 2025
0b73f52
refactor(ui): Add `ObservableItemsTransaction::push_local`.
Hywan May 6, 2025
a5d9eec
refactor(ui): Add `ObservableItemsTransaction::has_local`.
Hywan May 6, 2025
f8967b2
chore(base): Move the `bitflags` dependency in the workspace.
Hywan May 7, 2025
43dbce5
feat(ui): Define _regions_ in the `Timeline`.
Hywan May 7, 2025
af465fc
refactor(ui): `DateDividerAdjuster` works on _remotes_ and _locals_ r…
Hywan May 7, 2025
ec09b40
refactor(ui): `ReadReceiptTimelineUpdate` works on _remotes_ region.
Hywan May 7, 2025
9092f44
refactor(ui): `TimelineMetadata` works on the _remotes_ region.
Hywan May 7, 2025
52b8ac0
refactor(ui): `TimelineStateTransaction` works on _remotes_ and _all_…
Hywan May 7, 2025
0122d11
refactor(ui): `EventHandler` uses regions to improve the code and avo…
Hywan May 7, 2025
29ae0eb
chore(ui): Make Clippy happy.
Hywan May 12, 2025
d108829
doc(ui): Add #5000 in the `CHANGELOG.md`.
Hywan May 12, 2025
b7149b0
test(ui): Add tests for `push_local` and `push_date_divider`.
Hywan May 12, 2025
4b0a2e6
doc(ui): Fix a typo in a comment.
Hywan May 12, 2025
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
15 changes: 13 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,8 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
);

// Local events are always at the bottom. Let's find the latest remote event
// and insert after it, otherwise, if there is no remote event, insert at 0.
// and insert after it, otherwise, if there is no remote event, insert at 0 or 1
// depending of the presence of the `TimelineStart` virtual item.
let timeline_item_index = self
.items
.iter()
Expand All @@ -1222,7 +1223,17 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> {
(!timeline_item.as_event()?.is_local_echo())
.then_some(timeline_item_index + 1)
})
.unwrap_or(0);
.unwrap_or_else(|| {
// We don't have any local echo, so we could insert at 0. However, in
// the case of an insertion caused by a pagination, we
// may have already pushed the start of the timeline item, so we need
// to check if the first item is that, and insert after it otherwise.
if self.items.get(0).is_some_and(|item| item.is_timeline_start()) {
1
} else {
0
}
});

let event_index = self
.items
Expand Down
Loading