Skip to content
Snippets Groups Projects
Unverified Commit 93d225fd authored by Timo Kösters's avatar Timo Kösters
Browse files

improvement: faster way to load required state

parent 1bd9fd74
No related branches found
No related tags found
No related merge requests found
...@@ -376,24 +376,29 @@ async fn sync_helper( ...@@ -376,24 +376,29 @@ async fn sync_helper(
let mut state_events = Vec::new(); let mut state_events = Vec::new();
let mut lazy_loaded = Vec::new(); let mut lazy_loaded = Vec::new();
for (_, id) in current_state_ids { for (shortstatekey, id) in current_state_ids {
let pdu = match db.rooms.get_pdu(&id)? { let (event_type, state_key) = db.rooms.get_statekey_from_short(shortstatekey)?;
Some(pdu) => pdu,
None => { if event_type != EventType::RoomMember {
error!("Pdu in state not found: {}", id); let pdu = match db.rooms.get_pdu(&id)? {
continue; Some(pdu) => pdu,
} None => {
}; error!("Pdu in state not found: {}", id);
let state_key = pdu continue;
.state_key }
.as_ref() };
.expect("state events have state keys");
if pdu.kind != EventType::RoomMember {
state_events.push(pdu); state_events.push(pdu);
} else if !lazy_load_enabled } else if !lazy_load_enabled
|| body.full_state || body.full_state
|| timeline_users.contains(state_key) || timeline_users.contains(&state_key)
{ {
let pdu = match db.rooms.get_pdu(&id)? {
Some(pdu) => pdu,
None => {
error!("Pdu in state not found: {}", id);
continue;
}
};
lazy_loaded.push( lazy_loaded.push(
UserId::parse(state_key.as_ref()) UserId::parse(state_key.as_ref())
.expect("they are in timeline_users, so they should be correct"), .expect("they are in timeline_users, so they should be correct"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment