fix: Use prepare_lazily_loaded_members for joined rooms
Also, don't take read receipts into consideration for lazy loading. Synapse doesn't do this and they're making initial syncs very large.
This commit is contained in:
parent
19e895b57f
commit
5fb49d8668
2 changed files with 16 additions and 36 deletions
|
|
@ -13,7 +13,7 @@ use conduwuit::{
|
|||
stream::{Tools, WidebandExt},
|
||||
},
|
||||
};
|
||||
use conduwuit_service::{Services, rooms::lazy_loading::MemberSet};
|
||||
use conduwuit_service::Services;
|
||||
use futures::{
|
||||
FutureExt, StreamExt, TryFutureExt,
|
||||
future::{OptionFuture, join, join3, join4, try_join},
|
||||
|
|
@ -37,7 +37,7 @@ use super::{load_timeline, share_encrypted_room};
|
|||
use crate::client::{
|
||||
ignored_filter,
|
||||
sync::v3::{
|
||||
DeviceListUpdates, SyncContext,
|
||||
DeviceListUpdates, SyncContext, prepare_lazily_loaded_members,
|
||||
state::{calculate_state_incremental, calculate_state_initial},
|
||||
},
|
||||
};
|
||||
|
|
@ -199,32 +199,10 @@ pub(super) async fn load_joined_room(
|
|||
|content: RoomMemberEventContent| content.membership != MembershipState::Join,
|
||||
);
|
||||
|
||||
let lazy_loading_context = &sync_context.lazy_loading_context(room_id);
|
||||
|
||||
// the user IDs of members whose membership needs to be sent to the client, if
|
||||
// lazy-loading is enabled.
|
||||
let lazily_loaded_members =
|
||||
OptionFuture::from(sync_context.lazy_loading_enabled().then(|| {
|
||||
let timeline_and_receipt_members: MemberSet = timeline
|
||||
.senders()
|
||||
.chain(receipt_events.keys().map(Into::into))
|
||||
.collect();
|
||||
|
||||
services
|
||||
.rooms
|
||||
.lazy_loading
|
||||
.retain_lazy_members(timeline_and_receipt_members, lazy_loading_context)
|
||||
}))
|
||||
.await;
|
||||
|
||||
// reset lazy loading state on initial sync
|
||||
if previous_sync_end_count.is_none() {
|
||||
services
|
||||
.rooms
|
||||
.lazy_loading
|
||||
.reset(lazy_loading_context)
|
||||
.await;
|
||||
}
|
||||
prepare_lazily_loaded_members(services, sync_context, room_id, timeline.senders()).await;
|
||||
|
||||
/*
|
||||
compute the state delta between the previous sync and this sync. if this is an initial sync
|
||||
|
|
|
|||
|
|
@ -430,8 +430,19 @@ async fn prepare_lazily_loaded_members(
|
|||
) -> Option<MemberSet> {
|
||||
let lazy_loading_context = &sync_context.lazy_loading_context(room_id);
|
||||
|
||||
// the user IDs of members whose membership needs to be sent to the client, if
|
||||
// lazy-loading is enabled.
|
||||
// reset lazy loading state on initial sync.
|
||||
// do this even if lazy loading is disabled so future lazy loads
|
||||
// will have the correct members.
|
||||
if sync_context.since.is_none() {
|
||||
services
|
||||
.rooms
|
||||
.lazy_loading
|
||||
.reset(lazy_loading_context)
|
||||
.await;
|
||||
}
|
||||
|
||||
// filter the input members through `retain_lazy_members`, which
|
||||
// contains the actual lazy loading logic.
|
||||
let lazily_loaded_members =
|
||||
OptionFuture::from(sync_context.lazy_loading_enabled().then(|| {
|
||||
services
|
||||
|
|
@ -441,14 +452,5 @@ async fn prepare_lazily_loaded_members(
|
|||
}))
|
||||
.await;
|
||||
|
||||
// reset lazy loading state on initial sync
|
||||
if sync_context.since.is_none() {
|
||||
services
|
||||
.rooms
|
||||
.lazy_loading
|
||||
.reset(lazy_loading_context)
|
||||
.await;
|
||||
}
|
||||
|
||||
lazily_loaded_members
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue