lazy-construct presence; avoids useless db queries in sender and syncer.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
8b003e6be2
commit
33cc3d56c1
5 changed files with 16 additions and 11 deletions
|
@ -571,7 +571,7 @@ async fn process_presence_updates(
|
|||
presence_updates: &mut HashMap<OwnedUserId, PresenceEvent>, since: u64, syncing_user: &OwnedUserId,
|
||||
) -> Result<()> {
|
||||
// Take presence updates
|
||||
for (user_id, _, presence_event) in services().presence.presence_since(since) {
|
||||
for (user_id, _, presence_bytes) in services().presence.presence_since(since) {
|
||||
if !services()
|
||||
.rooms
|
||||
.state_cache
|
||||
|
@ -580,6 +580,8 @@ async fn process_presence_updates(
|
|||
continue;
|
||||
}
|
||||
|
||||
use crate::service::presence::Presence;
|
||||
let presence_event = Presence::from_json_bytes_to_event(&presence_bytes, &user_id)?;
|
||||
match presence_updates.entry(user_id) {
|
||||
Entry::Vacant(slot) => {
|
||||
slot.insert(presence_event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue