Focus the currently active project if there is one

(also consider your own projects in "most_active_projects")
This commit is contained in:
Conrad Irwin 2023-10-09 12:05:26 -06:00
parent 6084486dcd
commit abfb4490d5
2 changed files with 34 additions and 6 deletions

View file

@ -605,7 +605,7 @@ impl Room {
}
/// Returns the most 'active' projects, defined as most people in the project
pub fn most_active_project(&self) -> Option<(u64, u64)> {
pub fn most_active_project(&self, cx: &AppContext) -> Option<(u64, u64)> {
let mut projects = HashMap::default();
let mut hosts = HashMap::default();
@ -622,6 +622,13 @@ impl Room {
}
}
if let Some(user) = self.user_store.read(cx).current_user() {
for project in &self.local_participant.projects {
*projects.entry(project.id).or_insert(0) += 1;
hosts.insert(project.id, user.id);
}
}
let mut pairs: Vec<(u64, usize)> = projects.into_iter().collect();
pairs.sort_by_key(|(_, count)| *count as i32);