From 4128e2ffcbb5317ffc668c0c851e3a51474649e2 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 6 Oct 2023 15:18:25 -0600 Subject: [PATCH] Fix panic if the host is not there. --- crates/call/src/room.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 72db174d72..2543697bc0 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -602,6 +602,7 @@ impl Room { pub fn most_active_project(&self) -> Option<(u64, u64)> { let mut projects = HashMap::default(); let mut hosts = HashMap::default(); + for participant in self.remote_participants.values() { match participant.location { ParticipantLocation::SharedProject { project_id } => { @@ -619,8 +620,8 @@ impl Room { pairs.sort_by_key(|(_, count)| *count as i32); pairs - .first() - .map(|(project_id, _)| (*project_id, hosts[&project_id])) + .iter() + .find_map(|(project_id, _)| hosts.get(project_id).map(|host| (*project_id, *host))) } async fn handle_room_updated(