mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-05 03:48:52 +01:00
fix: less load when lazy loading
This commit is contained in:
parent
03b174335c
commit
53de350908
1 changed files with 27 additions and 26 deletions
|
@ -453,38 +453,39 @@ async fn sync_helper(
|
||||||
let joined_since_last_sync = since_sender_member
|
let joined_since_last_sync = since_sender_member
|
||||||
.map_or(true, |member| member.membership != MembershipState::Join);
|
.map_or(true, |member| member.membership != MembershipState::Join);
|
||||||
|
|
||||||
let current_state_ids = db.rooms.state_full_ids(current_shortstatehash)?;
|
|
||||||
|
|
||||||
let since_state_ids = db.rooms.state_full_ids(since_shortstatehash)?;
|
|
||||||
|
|
||||||
let mut state_events = Vec::new();
|
let mut state_events = Vec::new();
|
||||||
let mut lazy_loaded = HashSet::new();
|
let mut lazy_loaded = HashSet::new();
|
||||||
|
|
||||||
for (key, id) in current_state_ids {
|
if since_shortstatehash != current_shortstatehash {
|
||||||
if body.full_state || since_state_ids.get(&key) != Some(&id) {
|
let current_state_ids = db.rooms.state_full_ids(current_shortstatehash)?;
|
||||||
let pdu = match db.rooms.get_pdu(&id)? {
|
let since_state_ids = db.rooms.state_full_ids(since_shortstatehash)?;
|
||||||
Some(pdu) => pdu,
|
|
||||||
None => {
|
|
||||||
error!("Pdu in state not found: {}", id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if pdu.kind == EventType::RoomMember {
|
for (key, id) in current_state_ids {
|
||||||
match UserId::parse(
|
if body.full_state || since_state_ids.get(&key) != Some(&id) {
|
||||||
pdu.state_key
|
let pdu = match db.rooms.get_pdu(&id)? {
|
||||||
.as_ref()
|
Some(pdu) => pdu,
|
||||||
.expect("State event has state key")
|
None => {
|
||||||
.clone(),
|
error!("Pdu in state not found: {}", id);
|
||||||
) {
|
continue;
|
||||||
Ok(state_key_userid) => {
|
|
||||||
lazy_loaded.insert(state_key_userid);
|
|
||||||
}
|
}
|
||||||
Err(e) => error!("Invalid state key for member event: {}", e),
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
state_events.push(pdu);
|
if pdu.kind == EventType::RoomMember {
|
||||||
|
match UserId::parse(
|
||||||
|
pdu.state_key
|
||||||
|
.as_ref()
|
||||||
|
.expect("State event has state key")
|
||||||
|
.clone(),
|
||||||
|
) {
|
||||||
|
Ok(state_key_userid) => {
|
||||||
|
lazy_loaded.insert(state_key_userid);
|
||||||
|
}
|
||||||
|
Err(e) => error!("Invalid state key for member event: {}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state_events.push(pdu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue