Commit Graph

13223 Commits

Author SHA1 Message Date
Benjamin Bouvier
06759359af refactor(timeline): simplify lightly computation of should_add_new_items for local events 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
a3a30885c0 refactor(timeline): rename TimelineEventKind into TimelineAction and add comments 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
b448c4ac39 refactor(timeline): get rid of TimelineEventKind::Message 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
6a874fec2d refactor(timeline): use TimelineEventKind::AddItem for most room messages 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
998019b8b8 refactor(timeline): use TimelineEventKind::AddItem for poll starts 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
5a0b33fcd1 refactor(timeline): use TimelineEventKind::AddItem for call invite/notify/sticker 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
ec55d7cb58 refactor(timeline): use TimelineEventKind::HandleAggregation for poll edits/responses/ends 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
706f78d5b3 refactor(timeline): use TimelineEventKind::HandleAggregation for edits 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
1218cb4c28 refactor(timeline): use TimelineEventKind::HandleAggregation for redactions 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
31bd8a3587 refactor(timeline): introduce TimelineEventKind::HandleAggregation for non-items
This variant will be used to cause side-effects to existing timeline
items, because the event they relate to is for an aggregation
(edit/reaction/etc.).

This is used here for reactions.
2025-05-13 14:15:00 +02:00
Benjamin Bouvier
9e70cc5dde refactor(timeline): add a small helper function to create TimelineEventKind::AddItem items 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
d78a4927fd refactor(timeline): use TimelineEventKind::AddItem for room member and state events 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
bf246b6c09 refactor(timeline): use TimelineEventKind::AddItem for redacted messages 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
5da2235973 refactor(timeline): use TimelineEventKind::AddItem for UTDs 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
a9de4709f9 refactor(timeline): use TimelineEventKind::AddItem to insert failed-to-parse items 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
3b8d7ffacd refactor(timeline): introduce a new TimelineEventKind::AddItem variant
The intent is that the `TimelineItemContent` can be constructed in a
single place, avoiding the need to create it in multiple places.
2025-05-13 14:15:00 +02:00
Benjamin Bouvier
3eee5a4a92 refactor(timeline): bury one use of TimelineEventKind 2025-05-13 14:15:00 +02:00
Benjamin Bouvier
6fed5747bb refactor(timeline): remove another spurious is_own_event
Once again, this information is available in the `TimelineMetadata`.
2025-05-13 14:15:00 +02:00
Benjamin Bouvier
442094a725 refactor(timeline): remove spurious FullEventMeta::is_own_event
This information can be accessed via the `TimelineMetadata::own_user_id`
field, which is instantiated only once.
2025-05-13 14:15:00 +02:00
Benjamin Bouvier
de66047eee refactor(event cache): simplify Deduplicator so it only operates with the store impl 2025-05-13 10:17:21 +02:00
Benjamin Bouvier
48da03a148 refactor(event cache): don't make the store optional in the event cache 2025-05-13 10:17:21 +02:00
Benjamin Bouvier
13a2a8757e feat(event cache): enable storage by default \o/ 2025-05-13 10:17:21 +02:00
Benjamin Bouvier
1d901ec12a refactor(room list): get rid of the sliding sync in room_list_service::Room
This was only used to retrieve events cached in the timeline_queue().
2025-05-13 10:17:21 +02:00
Benjamin Bouvier
7115203a90 feat(event cache): get rid of add_initial_events() entirely 2025-05-13 10:17:21 +02:00
Jorge Martín
68fb60f223 test(ui): add more tests for fetching invite notifications in sliding sync 2025-05-13 09:10:44 +02:00
Jorge Martín
1f064fe474 test(ui): migrate notification fetching tests to use the batched methods
Also add one for the sliding sync + /context case
2025-05-13 09:10:44 +02:00
Jorge Martín
008c6f6d6c feat(ui): allow retrieving push notification events in batches 2025-05-13 09:10:44 +02:00
Yousef Moazzam
1afad3ab78 test: remove import of unused sync_timeline_event! macro 2025-05-13 09:04:55 +02:00
Yousef Moazzam
d1802086ad test: create room canonical alias events with EventFactory 2025-05-13 09:04:55 +02:00
Yousef Moazzam
cabe9632af test: add room canonical alias event method to EventFactory 2025-05-13 09:04:55 +02:00
Ivan Enderlin
08aa9c8614 doc(ui): Fix a typo in a comment. 2025-05-12 17:15:43 +02:00
Ivan Enderlin
831bba5cf0 test(ui): Add tests for push_local and push_date_divider. 2025-05-12 17:15:43 +02:00
Ivan Enderlin
d727111a51 doc(ui): Add #5000 in the CHANGELOG.md. 2025-05-12 17:15:43 +02:00
Ivan Enderlin
8d785b762e chore(ui): Make Clippy happy. 2025-05-12 17:15:43 +02:00
Ivan Enderlin
ad4ae230d5 refactor(ui): EventHandler uses regions to improve the code and avoid bugs.
This patch updates `EventHandler` to use the correct regions where
appropriate, thus reducing the complexity of the code, and removing
classes of bugs.

In the case of `Flow::Remote { position: TimelineItemPosition::At { …
}}`, we no longer need to skip the local timeline items, and to handle
the presence of the `TimelineStart` timeline item. The code is less
complex.

In the case of `Flow::Remote { position: TimelineItemPosition::End { …
}}`, that's exactly the same at the previous case.

In the case of `recycle_local_or_create_item`, the `try_fold` approach
is replaced entirely with a simple `iter_locals_region`, reducing the
size of the comments explaining the code, reducing the complexity of the
code, and reducing the surface of bugs.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
54f7963152 refactor(ui): TimelineStateTransaction works on _remotes_ and _all_ regions.
This patch updates `TimelineStateTransaction` to work on the correct
regions, _remotes_ in one place, and all regions in another place.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
b59c0b671e refactor(ui): TimelineMetadata works on the _remotes_ region.
This patch updates `TimelineMetadata` to work on the _remotes_ region
only, excluding the _start_ and the _locals_ regions. It helps to reduce
the risk of inserting items in an incorrect regions.

This patch also removes on more `rfind_event_by_id` usage, which is
nice.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
c6453a4cb3 refactor(ui): ReadReceiptTimelineUpdate works on _remotes_ region.
This patch updates `ReadReceiptTimelineUpdate` to work on the _remotes_
region only, excluding the _start_ and the _lcoals_ regions. It helps
to reduce the risk of inserting a `ReadMarker` inside the _start_ or the
_locals_ regions.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
74bf699615 refactor(ui): DateDividerAdjuster works on _remotes_ and _locals_ regions.
This patch updates `DateDividerAdjuster` to work on _remotes_ and
_locals_ regions only, excluding the _start_ region. It helps to reduce
the risk of inserting a `DateDivider` inside the _start_ region.

This patch also uses the new `push_date_divider` method, which provides
a couple of invariants.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
e1f94bf9c4 feat(ui): Define _regions_ in the Timeline.
This patch defines a new concept in the `Timeline`: Regions.

The `ObservableItems` holds all the invariants about the _position_ of the
items. It defines three regions where items can live:

1. the _start_ region, which can only contain a single `TimelineStart`,
2. the _remotes_ region, which can only contain many `Remote` timeline
   items with their decorations (only `DateDivider`s and `ReadMarker`s),
3. the _locals_ region, which can only contain many `Local` timeline items
   with their decorations (only `DateDivider`s).

The `iter_all_regions` method allows to iterate over all regions.
`iter_remotes_region` will restrict the iterator over the _remotes_
region, and so on. These iterators provide the absolute indices of the
items, so that it's harder to make mistakes when manipulating the indices of
items with operations like `insert`, `remove`, `replace` etc.

Other methods like `push_local` or `push_date_divider` insert the items
in the correct region, and check a couple of invariants.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
44a0745110 chore(base): Move the bitflags dependency in the workspace. 2025-05-12 17:15:43 +02:00
Ivan Enderlin
94b76168e8 refactor(ui): Add ObservableItemsTransaction::has_local.
This patch implements the `has_local` method on
`ObservableItemsTransaction`, which is way faster than the previous the
previous solution which was to iterate over all items to find at least
one local timeline item.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
55ea80b485 refactor(ui): Add ObservableItemsTransaction::push_local.
This patch adds the `push_local` method on `ObservableItemsTransaction`
to add semantics and hardcode the invariant in a single place for the
different timeline items.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
4e501e88ee refactor(ui): Add ObservableItemsTransaction::push_timeline_start_if_missing.
This patch adds the `push_timeline_start_if_missing` method on
`ObservableItemsTransaction` to add semantics and hardcode the
invariant in a single place for the different timeline items.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
afc02781e9 test(ui): Add a regression test.
This patch adds a regression test ensuring [this bug][4976] cannot
happen anymore.

[4976]: https://github.com/matrix-org/matrix-rust-sdk/issues/4976
2025-05-12 17:15:43 +02:00
Ivan Enderlin
c2072e1cc2 test(ui): Support index [$nth] --- date divider --- in assert_timeline_stream!. 2025-05-12 17:15:43 +02:00
Ivan Enderlin
eef99b2679 test: Add assert messages in the assert_timeline_stream macro.
This patch improves the `assert_timeline_stream` macro by adding a bunch
of assert messages in case it fails.
2025-05-12 17:15:43 +02:00
Ivan Enderlin
581d54f65f fix(ui): Offset the timeline index in the presence of a TimelineStart.
This patch fixes the insertion of a new `TimelineItem` in the presence
of a `TimelineStart` that shifts/offsets the timeline index of 1.
2025-05-12 17:15:43 +02:00
dependabot[bot]
5f5ea69a32 chore(deps): Bump tj-actions/changed-files
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 4168bb487d5b82227665ab4ec90b67ce02691741 to 480f49412651059a414a6a5c96887abb1877de8a.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](4168bb487d...480f494126)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: 480f49412651059a414a6a5c96887abb1877de8a
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-12 17:00:46 +02:00
Johannes Marbach
08800f7d60 Reduce boilerplate further 2025-05-12 10:56:57 +02:00