mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Changed the on-click behavior of joining a channel to not open the chat, and only open 1 project instead of all projects
Co-authored-by: conrad <conrad.irwin@gmail.com> Co-authored-by: max <max@zed.dev>
This commit is contained in:
parent
e548572f12
commit
dd0edcd203
2 changed files with 12 additions and 25 deletions
|
@ -598,9 +598,8 @@ impl Room {
|
||||||
.map_or(&[], |v| v.as_slice())
|
.map_or(&[], |v| v.as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// projects_to_join returns a list of shared projects sorted such
|
/// Returns the most 'active' projects, defined as most people in the project
|
||||||
/// that the most 'active' projects appear last.
|
pub fn most_active_project(&self) -> Option<(u64, u64)> {
|
||||||
pub fn projects_to_join(&self) -> Vec<(u64, u64)> {
|
|
||||||
let mut projects = HashMap::default();
|
let mut projects = HashMap::default();
|
||||||
let mut hosts = HashMap::default();
|
let mut hosts = HashMap::default();
|
||||||
for participant in self.remote_participants.values() {
|
for participant in self.remote_participants.values() {
|
||||||
|
@ -617,12 +616,11 @@ impl Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut pairs: Vec<(u64, usize)> = projects.into_iter().collect();
|
let mut pairs: Vec<(u64, usize)> = projects.into_iter().collect();
|
||||||
pairs.sort_by_key(|(_, count)| 0 - *count as i32);
|
pairs.sort_by_key(|(_, count)| *count as i32);
|
||||||
|
|
||||||
pairs
|
pairs
|
||||||
.into_iter()
|
.first()
|
||||||
.map(|(project_id, _)| (project_id, hosts[&project_id]))
|
.map(|(project_id, _)| (*project_id, hosts[&project_id]))
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_room_updated(
|
async fn handle_room_updated(
|
||||||
|
|
|
@ -3208,27 +3208,16 @@ impl CollabPanel {
|
||||||
.update(&mut cx, |call, cx| call.join_channel(channel_id, cx))
|
.update(&mut cx, |call, cx| call.join_channel(channel_id, cx))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let tasks = room.update(&mut cx, |room, cx| {
|
let task = room.update(&mut cx, |room, cx| {
|
||||||
let Some(workspace) = workspace.upgrade(cx) else {
|
let workspace = workspace.upgrade(cx)?;
|
||||||
return vec![];
|
let (project, host) = room.most_active_project()?;
|
||||||
};
|
let app_state = workspace.read(cx).app_state().clone();
|
||||||
let projects = room.projects_to_join();
|
Some(workspace::join_remote_project(project, host, app_state, cx))
|
||||||
|
|
||||||
if projects.is_empty() {
|
|
||||||
ChannelView::open(channel_id, workspace, cx).detach();
|
|
||||||
return vec![];
|
|
||||||
}
|
|
||||||
room.projects_to_join()
|
|
||||||
.into_iter()
|
|
||||||
.map(|(project_id, user_id)| {
|
|
||||||
let app_state = workspace.read(cx).app_state().clone();
|
|
||||||
workspace::join_remote_project(project_id, user_id, app_state, cx)
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
});
|
});
|
||||||
for task in tasks {
|
if let Some(task) = task {
|
||||||
task.await?;
|
task.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
})
|
})
|
||||||
.detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
|
|
Loading…
Reference in a new issue