Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cc6366f
feat(sdk): Check if the `EventCacheStoreLock` is dirty in `LockedThre…
Hywan Mar 17, 2026
2262101
chore(sdk): Move `load_linked_chunk_metadata` inside `persistence`.
Hywan Mar 17, 2026
ef2b4d1
feat(sdk): Load the last chunk from the store for `ThreadEventCache`.
Hywan Mar 17, 2026
b815cef
feat(sdk): Shrink to last chunk when `ThreadEventCacheState` is reloa…
Hywan Mar 17, 2026
19cc0d3
feat(sdk): Support removing events from the store for `ThreadEventCac…
Hywan Mar 17, 2026
b20c6db
chore(sdk): Simplify code in `RoomPagination`.
Hywan Mar 19, 2026
366651c
feat(sdk): Use the in-memory and in-store deduplicator.
Hywan Mar 19, 2026
ea9518c
chore(sdk): Add a `trace!` log in `ThreadEventCacheStateLockWriteGuar…
Hywan Mar 19, 2026
82b17e1
chore(sdk): Add a `#[must_use]` to `ThreadEventCacheStateLockWriteGua…
Hywan Mar 19, 2026
5a8b3af
doc(sdk): Update an inline comment.
Hywan Mar 20, 2026
13caa33
doc(sdk): Fix a comment.
Hywan Mar 20, 2026
3d5a98a
chore(sdk): Use `use self::` to import from `self`.
Hywan Mar 20, 2026
3332f4b
chore(sdk): Make more `RoomEventCacheInner` fields private.
Hywan Mar 20, 2026
5523d01
feat(sdk): Create `ThreadEventCacheUpdateSender`.
Hywan Mar 20, 2026
36889da
feat(sdk): Paginate over the store for threads.
Hywan Mar 20, 2026
477b160
chore(sdk): Pass the prev-batch token from the sync up to the `Thread…
Hywan Mar 20, 2026
276c9bf
feat(sdk): Insert gaps in threads.
Hywan Mar 23, 2026
5f16774
test(sdk): Remove `test_gappy_sync_empties_all_threads`.
Hywan Mar 23, 2026
a3d7449
test(sdk): Rename `test_thread_can_paginate_even_if_seen_sync_event`.
Hywan Mar 23, 2026
a263268
test(sdk): Use a previously declared event.
Hywan Mar 23, 2026
12a1ef0
feat(sdk): A redacted event in a thread is no longer removed: it's up…
Hywan Mar 24, 2026
7fe2c70
chore(sdk): Make Clippy happy.
Hywan Mar 25, 2026
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
27 changes: 14 additions & 13 deletions crates/matrix-sdk/src/event_cache/caches/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ use ruma::{
events::{AnyRoomAccountDataEvent, AnySyncEphemeralRoomEvent, relation::RelationType},
serde::Raw,
};
pub(super) use state::{LockedRoomEventCacheState, RoomEventCacheStateLockWriteGuard};
pub use subscriber::RoomEventCacheSubscriber;
use tokio::sync::{Notify, broadcast::Receiver, mpsc};
use tracing::{instrument, trace, warn};
pub use updates::{
RoomEventCacheGenericUpdate, RoomEventCacheLinkedChunkUpdate, RoomEventCacheUpdate,
RoomEventCacheUpdateSender,
};

pub(super) use self::state::{LockedRoomEventCacheState, RoomEventCacheStateLockWriteGuard};
pub use self::{
subscriber::RoomEventCacheSubscriber,
updates::{
RoomEventCacheGenericUpdate, RoomEventCacheLinkedChunkUpdate, RoomEventCacheUpdate,
RoomEventCacheUpdateSender,
},
};
use super::{
super::{AutoShrinkChannelPayload, EventCacheError, EventsOrigin, Result, RoomPagination},
TimelineVectorDiffs,
Expand Down Expand Up @@ -248,7 +250,7 @@ impl RoomEventCache {
/// Return a [`ThreadPagination`] type useful for running back-pagination
/// queries in the `thread_id` thread.
pub async fn thread_pagination(&self, thread_id: OwnedEventId) -> Result<ThreadPagination> {
Ok(self.inner.state.write().await?.get_or_reload_thread(thread_id).pagination())
Ok(self.inner.state.write().await?.get_or_reload_thread(thread_id).await?.pagination())
}

/// Try to find a single event in this room, starting from the most recent
Expand Down Expand Up @@ -425,15 +427,15 @@ pub(super) struct RoomEventCacheInner {
/// The room id for this room.
room_id: OwnedRoomId,

pub weak_room: WeakRoom,
weak_room: WeakRoom,

/// State for this room's event cache.
pub state: LockedRoomEventCacheState,
state: LockedRoomEventCacheState,

/// A notifier that we received a new pagination token.
pub pagination_batch_token_notifier: Notify,
pagination_batch_token_notifier: Notify,

pub shared_pagination_status: SharedObservable<SharedPaginationStatus>,
shared_pagination_status: SharedObservable<SharedPaginationStatus>,

/// Sender to the auto-shrink channel.
///
Expand Down Expand Up @@ -461,7 +463,7 @@ impl RoomEventCacheInner {
weak_room,
state,
update_sender,
pagination_batch_token_notifier: Default::default(),
pagination_batch_token_notifier: Notify::new(),
auto_shrink_sender,
shared_pagination_status,
}
Expand Down Expand Up @@ -523,7 +525,6 @@ impl RoomEventCacheInner {
return Ok(());
}

// Add all the events to the backend.
trace!("adding new events");

let (stored_prev_batch_token, timeline_event_diffs) =
Expand Down
23 changes: 10 additions & 13 deletions crates/matrix-sdk/src/event_cache/caches/room/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,14 @@ impl PaginatedCache for Arc<RoomEventCacheInner> {
in_memory_duplicated_event_ids,
in_store_duplicated_event_ids,
non_empty_all_duplicates: all_duplicates,
} = {
let room_linked_chunk = state.room_linked_chunk();

filter_duplicate_events(
&state.state.own_user_id,
&state.store,
LinkedChunkId::Room(&state.state.room_id),
room_linked_chunk,
events,
)
.await?
};
} = filter_duplicate_events(
&state.state.own_user_id,
&state.store,
LinkedChunkId::Room(&state.state.room_id),
state.room_linked_chunk(),
events,
)
.await?;

// If not all the events have been back-paginated, we need to remove the
// previous ones, otherwise we can end up with misordered events.
Expand Down Expand Up @@ -404,7 +400,7 @@ impl PaginatedCache for Arc<RoomEventCacheInner> {
// the inverted order; reorder them.
let topo_ordered_events = events.iter().rev().cloned().collect::<Vec<_>>();

let new_gap = new_token.map(|prev_token| Gap { token: prev_token });
let new_gap = new_token.as_ref().map(|prev_token| Gap { token: prev_token.clone() });
let reached_start = state.room_linked_chunk_mut().push_backwards_pagination_events(
prev_gap_id,
new_gap,
Expand All @@ -424,6 +420,7 @@ impl PaginatedCache for Arc<RoomEventCacheInner> {
state
.post_process_new_events(
topo_ordered_events,
new_token,
PostProcessingOrigin::Backpagination,
receipt_event,
)
Expand Down
Loading
Loading