Implement specified non-blocking semantic for sliding-sync.

Simplify sliding-sync watch loop and bounds.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-10-22 20:53:04 +00:00
parent 4010fc62bc
commit 0397bb8237
5 changed files with 42 additions and 35 deletions

View File

@@ -99,11 +99,15 @@ pub(super) async fn handle(
.flat_ok()
.unwrap_or_else(|| (Vec::new(), true, PduCount::default()));
let required_state = required_state
.into_iter()
.filter(|_| !timeline_pdus.is_empty())
.collect::<Vec<_>>();
let prev_batch = timeline_pdus
.first()
.map(at!(0))
.map(PduCount::into_unsigned)
.or_else(|| roomsince.ne(&0).then_some(roomsince))
.as_ref()
.map(ToString::to_string);
@@ -152,14 +156,6 @@ pub(super) async fn handle(
.map(|sender| (StateEventType::RoomMember, StateKey::from_str(sender.as_str())))
.stream();
let timeline = timeline_pdus
.iter()
.stream()
.filter_map(|item| ignored_filter(services, item.clone(), sender_user))
.map(at!(1))
.map(Event::into_format)
.collect();
let wildcard_state = required_state
.iter()
.filter(|(_, state_key)| state_key == "*")
@@ -253,6 +249,14 @@ pub(super) async fn handle(
.user
.last_notification_read(sender_user, room_id);
let timeline = timeline_pdus
.iter()
.stream()
.filter_map(|item| ignored_filter(services, item.clone(), sender_user))
.map(at!(1))
.map(Event::into_format)
.collect();
let meta = join3(room_name, room_avatar, is_dm);
let events = join4(timeline, num_live, required_state, invite_state);
let member_counts = join(joined_count, invited_count);

View File

@@ -174,7 +174,6 @@ async fn match_lists_for_room(
services
.user
.last_notification_read(sender_user, &room_id)
.map(|count| count.min(conn.next_batch))
})
.into();
@@ -183,23 +182,19 @@ async fn match_lists_for_room(
services
.read_receipt
.last_privateread_update(sender_user, &room_id)
.map(|count| count.min(conn.next_batch))
})
.into();
let last_receipt: OptionFuture<_> = matched
.and_is(false) // masked out, maybe unnecessary
.then(|| {
services
.read_receipt
.last_receipt_count(&room_id, sender_user.into(), None)
.unwrap_or_default()
.map(|count| count.min(conn.next_batch))
})
.into();
let last_account: OptionFuture<_> = matched
.and_is(false) // masked out, maybe unnecessary
.then(|| {
services
.account_data
@@ -236,6 +231,7 @@ async fn match_lists_for_room(
]
.into_iter()
.map(Option::unwrap_or_default)
.filter(|count| conn.next_batch.ge(count))
.max()
.unwrap_or_default(),
})