mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-01-01 05:54:26 +01:00
improvement: faster way to load required state
This commit is contained in:
parent
1bd9fd74b3
commit
93d225fd1e
1 changed files with 19 additions and 14 deletions
|
@ -376,7 +376,10 @@ 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 (event_type, state_key) = db.rooms.get_statekey_from_short(shortstatekey)?;
|
||||||
|
|
||||||
|
if event_type != EventType::RoomMember {
|
||||||
let pdu = match db.rooms.get_pdu(&id)? {
|
let pdu = match db.rooms.get_pdu(&id)? {
|
||||||
Some(pdu) => pdu,
|
Some(pdu) => pdu,
|
||||||
None => {
|
None => {
|
||||||
|
@ -384,16 +387,18 @@ async fn sync_helper(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let state_key = pdu
|
|
||||||
.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"),
|
||||||
|
|
Loading…
Reference in a new issue