chore(sync/v3): Use "build_*" terminology instead of "calculate_*"

This commit is contained in:
Ginger 2025-11-05 10:04:43 -05:00
parent 9cc0cc69f7
commit 876d3faec4
3 changed files with 14 additions and 14 deletions

View file

@ -38,7 +38,7 @@ use crate::client::{
ignored_filter, ignored_filter,
sync::v3::{ sync::v3::{
DeviceListUpdates, SyncContext, prepare_lazily_loaded_members, DeviceListUpdates, SyncContext, prepare_lazily_loaded_members,
state::{calculate_state_incremental, calculate_state_initial}, state::{build_state_incremental, build_state_initial},
}, },
}; };
@ -194,14 +194,14 @@ pub(super) async fn load_joined_room(
/* /*
compute the state delta between the previous sync and this sync. if this is an initial sync compute the state delta between the previous sync and this sync. if this is an initial sync
*or* we just joined this room, `calculate_state_initial` will be used, otherwise `calculate_state_incremental` *or* we just joined this room, `build_state_initial` will be used, otherwise `build_state_incremental`
will be used. will be used.
*/ */
let mut state_events = if let Some(last_sync_end_count) = last_sync_end_count let mut state_events = if let Some(last_sync_end_count) = last_sync_end_count
&& let Some(last_sync_end_shortstatehash) = last_sync_end_shortstatehash && let Some(last_sync_end_shortstatehash) = last_sync_end_shortstatehash
&& !full_state && !full_state
{ {
calculate_state_incremental( build_state_incremental(
services, services,
syncing_user, syncing_user,
room_id, room_id,
@ -215,7 +215,7 @@ pub(super) async fn load_joined_room(
.boxed() .boxed()
.await? .await?
} else { } else {
calculate_state_initial( build_state_initial(
services, services,
syncing_user, syncing_user,
timeline_start_shortstatehash, timeline_start_shortstatehash,
@ -227,7 +227,7 @@ pub(super) async fn load_joined_room(
// for incremental syncs, calculate updates to E2EE device lists // for incremental syncs, calculate updates to E2EE device lists
if last_sync_end_count.is_some() && is_encrypted_room { if last_sync_end_count.is_some() && is_encrypted_room {
calculate_device_list_updates( extend_device_list_updates(
services, services,
sync_context, sync_context,
room_id, room_id,
@ -243,7 +243,7 @@ pub(super) async fn load_joined_room(
let (joined_member_count, invited_member_count, heroes) = let (joined_member_count, invited_member_count, heroes) =
// calculate counts if any of the state events we're syncing are of type `m.room.member` // calculate counts if any of the state events we're syncing are of type `m.room.member`
if state_events.iter().any(|event| event.kind == RoomMember) { if state_events.iter().any(|event| event.kind == RoomMember) {
calculate_counts(services, room_id, syncing_user).await? build_room_summary(services, room_id, syncing_user).await?
} else { } else {
(None, None, None) (None, None, None)
}; };
@ -416,7 +416,7 @@ pub(super) async fn load_joined_room(
Ok((joined_room, device_list_updates)) Ok((joined_room, device_list_updates))
} }
async fn calculate_device_list_updates( async fn extend_device_list_updates(
services: &Services, services: &Services,
SyncContext { SyncContext {
syncing_user, syncing_user,
@ -479,7 +479,7 @@ async fn calculate_device_list_updates(
} }
} }
async fn calculate_counts( async fn build_room_summary(
services: &Services, services: &Services,
room_id: &RoomId, room_id: &RoomId,
syncing_user: &UserId, syncing_user: &UserId,
@ -502,13 +502,13 @@ async fn calculate_counts(
let small_room = joined_member_count.saturating_add(invited_member_count) <= 5; let small_room = joined_member_count.saturating_add(invited_member_count) <= 5;
let heroes: OptionFuture<_> = small_room let heroes: OptionFuture<_> = small_room
.then(|| calculate_heroes(services, room_id, syncing_user)) .then(|| build_heroes(services, room_id, syncing_user))
.into(); .into();
Ok((Some(joined_member_count), Some(invited_member_count), heroes.await)) Ok((Some(joined_member_count), Some(invited_member_count), heroes.await))
} }
async fn calculate_heroes( async fn build_heroes(
services: &Services, services: &Services,
room_id: &RoomId, room_id: &RoomId,
syncing_user: &UserId, syncing_user: &UserId,

View file

@ -21,7 +21,7 @@ use crate::client::{
TimelinePdus, ignored_filter, TimelinePdus, ignored_filter,
sync::{ sync::{
load_timeline, load_timeline,
v3::{SyncContext, prepare_lazily_loaded_members, state::calculate_state_initial}, v3::{SyncContext, prepare_lazily_loaded_members, state::build_state_initial},
}, },
}; };
@ -192,7 +192,7 @@ pub(super) async fn load_left_room(
// TODO: calculate incremental state for incremental syncs. // TODO: calculate incremental state for incremental syncs.
// always calculating initial state _works_ but returns more data and does // always calculating initial state _works_ but returns more data and does
// more processing than strictly necessary. // more processing than strictly necessary.
let state = calculate_state_initial( let state = build_state_initial(
services, services,
syncing_user, syncing_user,
timeline_start_shortstatehash, timeline_start_shortstatehash,

View file

@ -35,7 +35,7 @@ use crate::client::TimelinePdus;
fields(current_shortstatehash) fields(current_shortstatehash)
)] )]
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub(super) async fn calculate_state_initial( pub(super) async fn build_state_initial(
services: &Services, services: &Services,
sender_user: &UserId, sender_user: &UserId,
timeline_start_shortstatehash: ShortStateHash, timeline_start_shortstatehash: ShortStateHash,
@ -89,7 +89,7 @@ pub(super) async fn calculate_state_initial(
/// `lazily_loaded_members`. /// `lazily_loaded_members`.
#[tracing::instrument(name = "incremental", level = "trace", skip_all)] #[tracing::instrument(name = "incremental", level = "trace", skip_all)]
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub(super) async fn calculate_state_incremental<'a>( pub(super) async fn build_state_incremental<'a>(
services: &Services, services: &Services,
sender_user: &'a UserId, sender_user: &'a UserId,
room_id: &RoomId, room_id: &RoomId,