This patch renames `TimelineEventKind::event_id` to `parse_event_id`,
and `sender` to `parse_sender` to make it explicit it _parses_ the data,
which has a cost!
This patch updates `aggregate_timeline_for_threads` to look for the
thread roots in the `Timeline` type itself before looking inside the
`RoomEventCache`. It improves performance as it is not unusual to have
an event plus its edit, or some reactions, all together in the same
sync payload. Consequently, we don't need to hit the `RoomEventCache`'
state, so no lock, no in-memory look up inside this state (note that we
don't save a store look up as hitting the store would require the event
to be absent of the sync payload: all events received by the current
sync must live in memory).
This patch fixes an issue where an in-thread encrypted event was
**always** part of the `TimelineFocusKind::Live` timeline regardless of
the `hide_threaded_events` value. The Event Cache is able to know
whether an encrypted event is part of a thread, so the Timeline can do
the same!
Consequently, an in-thread encrypted event no longer appears in the
main timeline if `hide_threaded_events` is `true`, to then be removed
once decrypted.
It fixes/removes one `TODO` in a test.
This patch updates R2D2 to uses `Caches` via
`EventCache::inner::all_caches_for_room` to get a reference to all the
caches. It updates the way the event-focused cache was updated. No more
ABBA lock problem here. The code is simplified.
This patch removes the `room` argument of
`EventFocusedCache(Inner)::start_from`. First off, this is not required
as the struct already has the `WeakRoom`. Second, this is dangerous as
the two rooms might differ, or different rooms might be used between
called. This can be really inconsistent.
This patch removes the `room` argument and the code uses the `WeakRoom`
in the struct instead.
This patch moves `maybe_add_live_related_events` to `handle_timeline`.
`handle_timeline` is called by `handle_(joined|left)_room_update`, which
are themselves called by `Caches`.
This patch also removes other methods used by
`maybe_add_live_related_events` but are no longer useful since
we have the aggregator, namely `extract_relation_target` and
`extract_redaction_target`.
Finally, this patch removes the call to `maybe_add_live_related_events`
in `RoomEventCacheStateLockWriteGuard::post_process_new_events`, which
removes the need to acquire a write lock over the room' state here.
This patch adds `EventCache::pinned_events` to get the `PinnedEventsCache`.
This patch adds `Caches::pinned_events`. `ResetCaches` also
handle the pinned-events cache. To make it works, this patch adds
`PinnedEventsCache::state`, `PinnedEventsCache::update_sender` and
`PinnedEventsCacheStateLockWriteGuard::reset`. This one is new as the
feature wasn't implemented before!
This patch adds `PinnedEventsCacheInner::update_sender`, making
`PinnedEventsCacheState::update_sender` a clone of the former.
This is going to be useful in the next commit for handling pinned-events
in `ResetCaches`.
This patch introduces the `PinnedEventsCacheInner` type that is used
inside `PinnedEventsCache` to make it cheap to clone. It was already the
case before with all the fields beind `Arc<_>` but we are about to move
data in their correct place, and thus it will add more `Arc<_>`, which
is not good. Let's adopt the same patterns as the other caches too for
the sake of consistency.
This patch introduces the new type `PinnedEventsCacheUpdateSender` _à
la_ `ThreadEventCacheUpdateSender` or `RoomEventCacheUpdateSender`. It
abstracts the channels to send updates about. Yes, for the moment, it
has a single channel, but it's better to provide the same abstractions
for all caches.
This patch renames `PinnedEventsCacheStateLock` to
`LockedPinnedEventsCacheState` to match other namings in
`RoomEventCache` and `ThreadEventCache` for the sake of consistency.
This patch changes `PinnedEventsCache::new` to receive a `WeakRoom`
instead of a `Room`. It then returns a `Result<Self>`, with `Err` if the
`WeakRoom` doesn't point to the `Room` anymore. Thus, this patch changes
`get_or_init` by `get_or_try_init`, but this one is unstable. So this
patch switches from `OnceLock` to `OnceCell`, which provides a stable
one. Why this change? Because in a later refactoring, providing a `Room`
is a bit annoying: all we will have is a `WeakRoom`. We could do this
work of upgrading the `WeakRoom` to a `Room`, but it seems akward as all
caches are holding a `WeakRoom` if room is necessary.
This patch renames `PinnedEventCache` to `PinnedEventsCache` (and same
for all types having `PinnedEventCache` as a prefix).
Why? Because it's a cache about _pinned-events_, not a single
_pinned-event_ :-).