Skip to content

Commit a8bfb7b

Browse files
committed
fixup! feat(event cache): automatically subscribe to threads according to msc4306 semantics
1 parent 8da211c commit a8bfb7b

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

crates/matrix-sdk/src/event_cache/room/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ mod private {
15361536
if let Some(subscribe_to_event_id) =
15371537
should_subscribe_thread(&push_context, new_events.iter()).await
15381538
{
1539-
thread_subscriptions.0.insert(thread_root.clone(), subscribe_to_event_id);
1539+
thread_subscriptions.insert(thread_root.clone(), subscribe_to_event_id);
15401540
}
15411541

15421542
// If we're not in sync mode, we're receiving events from a room pagination: as

crates/matrix-sdk/src/event_cache/room/threads.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ impl ThreadEventCache {
275275
subscribe_to_event_id = Some((self.thread_root.clone(), subscribed_to_event_id));
276276
}
277277

278-
let thread_subscriptions =
279-
AutomaticThreadSubscriptions(BTreeMap::from_iter(subscribe_to_event_id));
278+
let thread_subscriptions = AutomaticThreadSubscriptions::from_iter(subscribe_to_event_id);
280279

281280
Some((BackPaginationOutcome { reached_start, events }, thread_subscriptions))
282281
}
@@ -292,8 +291,7 @@ impl ThreadEventCache {
292291
///
293292
/// Note: it's not necessarily the latest event in the thread, but the latest in
294293
/// the thread that matches a push condition rule.
295-
#[derive(Debug, Default)]
296-
pub struct AutomaticThreadSubscriptions(pub BTreeMap<OwnedEventId, OwnedEventId>);
294+
pub type AutomaticThreadSubscriptions = BTreeMap<OwnedEventId, OwnedEventId>;
297295

298296
/// A thin wrapper over a specialized [`PushContext`] that is used for computing
299297
/// the threads subscriptions automatically.
@@ -362,11 +360,11 @@ pub async fn should_subscribe_thread(
362360
pub async fn subscribe_to_new_threads(room: &Room, new_thread_subs: AutomaticThreadSubscriptions) {
363361
// If there's no subscriptions, or the client hasn't enabled thread
364362
// subscriptions, we don't have anything to do.
365-
if new_thread_subs.0.is_empty() || !room.client.enabled_thread_subscriptions() {
363+
if new_thread_subs.is_empty() || !room.client.enabled_thread_subscriptions() {
366364
return;
367365
}
368366

369-
for (thread_root, subscribe_up_to_event_id) in new_thread_subs.0 {
367+
for (thread_root, subscribe_up_to_event_id) in new_thread_subs {
370368
let previous_status = match room.load_or_fetch_thread_subscription(&thread_root).await {
371369
Ok(status) => status,
372370
Err(err) => {

crates/matrix-sdk/src/room/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,6 +3071,7 @@ impl Room {
30713071
/// Retrieves a [`PushContext`] that can be used to compute the push actions
30723072
/// for events, with a choice to include thread subscriptions or not,
30733073
/// based on the extra `with_threads_subscriptions` parameter.
3074+
#[instrument(skip(self))]
30743075
pub(crate) async fn push_context_internal(
30753076
&self,
30763077
with_threads_subscriptions: bool,

0 commit comments

Comments
 (0)