-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ui): Deduplicate timeline items conditionnally.
A previous patch deduplicates the remote events conditionnally. This patch does the same but for timeline items. The `Timeline` has its own deduplication algorithm (for remote events, and for timeline items). The `Timeline` is about to receive its updates via the `EventCache` which has its own deduplication mechanism (`matrix_sdk::event_cache::Deduplicator`). To avoid conflicts between the two, we conditionnally deduplicate timeline items based on `TimelineSettings::vectordiffs_as_inputs`. This patch takes the liberty to refactor the deduplication mechanism of the timeline items to make it explicit with its own methods, so that it can be re-used for `TimelineItemPosition::At`. A specific short-circuit was present before, which is no more possible with the rewrite to a generic mechanism. Consequently, when a local timeline item becomes a remote timeline item, it was previously updated (via `ObservableItems::replace`), but now the local timeline item is removed (via `ObservableItems::remove`), and then the remote timeline item is inserted (via `ObservableItems::insert`). Depending of whether a virtual timeline item like a date divider is around, the position of the removal and the insertion might not be the same (!), which is perfectly fine as the date divider will be re-computed anyway. The result is exactly the same, but the `VectorDiff` updates emitted by the `Timeline` are a bit different (different paths, same result). This is why this patch needs to update a couple of tests.
- Loading branch information
Showing
8 changed files
with
252 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.