Commit Graph

15411 Commits

Author SHA1 Message Date
Ivan Enderlin
b3a2d991e4 doc(common): Add the changelog file. 2026-06-01 13:45:07 +02:00
Ivan Enderlin
8a1c88cf97 chore: Update code according to the new TimelineEvent::event_id() signature. 2026-06-01 13:45:07 +02:00
Ivan Enderlin
b0fa52f17f refactor(common): TimelineEvent::event_id now returns an Option<&EventId>.
This patch updates `TimelineEvent::event_id` to return an
`Option<&EventId>` instead of an `Option<OwnedEventId>`. It avoids
cloning the event ID.
2026-06-01 13:45:07 +02:00
Ivan Enderlin
d536dff709 test(common): Add a test to ensure TimelineEvent::replace_raw update the cached event ID. 2026-06-01 13:45:07 +02:00
Ivan Enderlin
a218ef4294 refactor(common): Rename TimelineEventKind::event_id and sender to parse_event_id and parse_sender.
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!
2026-06-01 13:45:07 +02:00
Ivan Enderlin
6758c08f19 perf(common): Cache TimelineEventKind::event_id() in TimelineEvent::event_id. 2026-06-01 13:45:07 +02:00
Ivan Enderlin
b3a065c871 doc(sdk): Fix typos. 2026-05-29 15:15:56 +02:00
Ivan Enderlin
469f6ba87e feat(sdk): aggregate_timeline_for_threads looks for thread roots in the timeline itself.
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).
2026-05-29 15:15:56 +02:00
Ivan Enderlin
876d2bb43a fix(ui): In-thread encrypted events are no long part of the main timeline if filtered out.
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.
2026-05-29 15:15:56 +02:00
Ivan Enderlin
d83754be4f test(sdk): Re-enable the test_latest_thread_event_is_redecrypted_and_updated test. 2026-05-29 15:15:56 +02:00
Ivan Enderlin
e79f83e5cc fix(sdk): Re-compute the ThreadSummary when R2D2 redecrypts an event in a thread. 2026-05-29 15:15:56 +02:00
Ivan Enderlin
b79dcd6328 fix(sdk): Restore UTD resolution on threads.
This patch restores UTD resolution on the thread caches. It has been
disabled earlier during this refactoring, now it's back!
2026-05-29 15:15:56 +02:00
Ivan Enderlin
4943c18d53 doc(sdk): Fix a typo in the documentation of Caches::all_events. 2026-05-29 14:36:10 +02:00
Ivan Enderlin
1568963dac feat(sdk): Allow to reset an EventFocusedCache.
This patch updates `ResetCaches` to handle the event-focused caches.
2026-05-29 14:36:10 +02:00
Ivan Enderlin
c72753dca2 refactor(sdk): Rename EventFocusedCacheInner to EventFocusedCacheState.
This patch renames `EventFocusedCacheInner` to `EventFocusedCacheState`
because it contains the state of the `EventFocusedCacheState`.
2026-05-29 14:36:09 +02:00
Ivan Enderlin
2836812c24 chore(sdk): Reorganise imports.
This patch reorganises the imports. Notably, `RoomPagination` is a
submodule: no need to import it from `crate::event_cache`.
2026-05-29 14:36:09 +02:00
Ivan Enderlin
cc4c89eb4f test(sdk): Update the tests. 2026-05-29 14:36:09 +02:00
Ivan Enderlin
27c62c99dd chore(sdk): Remove EventFocusedCache from RoomEventCache.
Moohaha.
2026-05-29 14:36:09 +02:00
Ivan Enderlin
4cbabb0cef refactor(sdk): R2D2 uses Caches directly to resolve UTD on various caches.
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.
2026-05-29 14:36:09 +02:00
Ivan Enderlin
773d24e502 chore(ui): TimelineController::new uses EventCache::event_focused. 2026-05-29 14:36:08 +02:00
Ivan Enderlin
57e9053f08 refactor(sdk): Rename focused to focused_event_id in EventFocusedCacheKey.
This patch renames the `EventFocusedCacheKey::focused` field to
`focused_event_id` to clarify what is focused.
2026-05-29 14:36:08 +02:00
Ivan Enderlin
0c92070894 feat(sdk): Add EventCache::event_focused.
This patch stores all the `EventFocusedCache` in `Caches`.
2026-05-29 14:36:08 +02:00
Ivan Enderlin
49df4f5fa7 fix(sdk): Remove the room argument of EventFocusedCache::start_from.
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.
2026-05-29 14:36:08 +02:00
Ivan Enderlin
b810426a6c chore(sdk): Save the creation of a WeakRoom from scratch since one already exists.
This patch clones an existing `WeakRoom` instead of creating another one
from scratch.
2026-05-29 14:36:08 +02:00
Ivan Enderlin
07aa61c295 feat(sdk): EventFocusedCacheKey implements Debug. 2026-05-29 14:36:07 +02:00
Ivan Enderlin
d9ce36163d refactor(sdk): Move EventFocusedCacheKey from room to event_focused.
This patch moves `EventFocusedCacheKey` from the `room` module into the
`event_focused` module because it's about the event-focused cache.
2026-05-29 14:36:07 +02:00
Ivan Enderlin
26fff112a4 chore: Remove an unused reload method. 2026-05-29 14:36:07 +02:00
Ivan Enderlin
788b80f3de test(sdk,ui): Update tests to the new API. 2026-05-29 14:36:07 +02:00
Ivan Enderlin
efa6bc9c8b chore(sdk): Remove PinnedEventsCache entirely from RoomEventCache.
This patch removes deadcode about `PinnedEventsCache` in `RoomEventCache`.
2026-05-29 14:36:06 +02:00
Ivan Enderlin
8d6ff18ef5 refactor(sdk): R2D2 replaces UTD on PinnedEventsCache without involving RoomEventCache.
This patch updates R2D2 to fetch the `PinnedEventsCache` from
`EventCache` without using `RoomEventCache`.
2026-05-29 14:36:06 +02:00
Ivan Enderlin
1047e14d2b chore(sdk): Remove subscribe_to_pinned_events.
This patch removes `subscribe_to_pinned_events`, it is now useless.
2026-05-29 14:36:06 +02:00
Ivan Enderlin
5ce4c667f3 feat(ui): TimelineFocusKind::PinnedEvents now uses PinnedEventsCache.
This patch updates `TimelineFocusKind::PinnedEvents { event_cache }` to
use a `PinnedEventsCache` instead of a `RoomEventCache`.
2026-05-29 14:36:06 +02:00
Ivan Enderlin
2c562ba20a chore(sdk): Simplify imports. 2026-05-29 14:36:05 +02:00
Ivan Enderlin
b1927f121c feat(sdk): PinnedEventsCache handles redaction.
This patch applies event redactions over pinned events.
2026-05-29 14:36:05 +02:00
Ivan Enderlin
8f287198eb feat(sdk): Deduplicate pinned events.
This patch runs the `filter_duplicate_events` function inside
`handle_sync` to deduplicate events related to pinned events.
2026-05-29 14:36:04 +02:00
Ivan Enderlin
9d0d609892 refactor(sdk): Handle the Timeline for pinned-events in Caches instead of RoomEventCache.
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.
2026-05-29 14:36:04 +02:00
Ivan Enderlin
9d0826252c feat(sdk): Add aggregator_timeline_for_pinned_events.
This patch adds the pipeline for `PinnedEventsCache` via
`aggregator_timeline_for_pinned_events`.
2026-05-29 14:36:03 +02:00
Ivan Enderlin
ca84cf833a feat(sdk): Add EventCache::pinned_events.
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!
2026-05-29 14:36:03 +02:00
Ivan Enderlin
4d241089b7 feat(sdk): Add PinnedEventsCacheInner::update_sender.
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`.
2026-05-29 14:36:03 +02:00
Ivan Enderlin
c853c77f8c refactor(sdk): Introduce PinnedEventsCacheInner.
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.
2026-05-29 14:36:02 +02:00
Ivan Enderlin
25abaefcb1 doc(sdk): Fix document in thread cache. 2026-05-29 14:36:02 +02:00
Ivan Enderlin
835ef77367 refactor(sdk): Introduce PinnedEventsCacheUpdateSender.
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.
2026-05-29 14:36:02 +02:00
Ivan Enderlin
f87363a0a6 doc(sdk): Fix an intra-link. 2026-05-29 14:36:01 +02:00
Ivan Enderlin
fbbffda11f refactor(sdk): Rename PinnedEventsCacheStateLock to LockedPinnedEventsCacheState.
This patch renames `PinnedEventsCacheStateLock` to
`LockedPinnedEventsCacheState` to match other namings in
`RoomEventCache` and `ThreadEventCache` for the sake of consistency.
2026-05-29 14:36:01 +02:00
Ivan Enderlin
00e610cdd2 chore(sdk): PinnedEventsCache::new takes a WeakRoom instead of a Room.
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.
2026-05-29 14:36:01 +02:00
Ivan Enderlin
3077d51ec8 refactor(sdk): Rename PinnedEventCache to PinnedEventsCache.
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_ :-).
2026-05-29 14:36:01 +02:00
Ivan Enderlin
48c1629791 doc(sdk): Remove a useless TODO. 2026-05-29 14:36:00 +02:00
Ivan Enderlin
f9df888cf3 chore(sdk): Implement Debug for PinnedEventCache. 2026-05-29 14:36:00 +02:00
Ivan Enderlin
d7f35742d4 test(sdj): Fix test_redact_touches_threads if async runtime is slow. 2026-05-29 14:36:00 +02:00
Ivan Enderlin
4d58a3c0db chore(sdk,ui): Fix typos. 2026-05-29 14:36:00 +02:00