Do more on channel join (#7268)
This change makes it so that if you are the first to join a channel, your project is automatically shared. It also makes it so that if you join a channel via a link and there are no shared projects, you open the notes instead of an empty workspace with nothing. This is to try and address the discoverability of project sharing: we've had two reviews that have talked about channels, but not talked about sharing projects into them, which makes me suspect they didn't know about the feature. Release Notes: - Added a setting `share_on_join` (defaulting to true). When set, and you join an empty channel, your project is automatically shared.
This commit is contained in:
parent
6f6cb53fad
commit
074acacdf7
5 changed files with 68 additions and 5 deletions
|
@ -12,7 +12,7 @@ mod toolbar;
|
|||
mod workspace_settings;
|
||||
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use call::ActiveCall;
|
||||
use call::{call_settings::CallSettings, ActiveCall};
|
||||
use client::{
|
||||
proto::{self, ErrorCode, PeerId},
|
||||
Client, ErrorExt, Status, TypedEnvelope, UserStore,
|
||||
|
@ -3974,6 +3974,8 @@ pub async fn last_opened_workspace_paths() -> Option<WorkspaceLocation> {
|
|||
DB.last_workspace().await.log_err().flatten()
|
||||
}
|
||||
|
||||
actions!(collab, [OpenChannelNotes]);
|
||||
|
||||
async fn join_channel_internal(
|
||||
channel_id: u64,
|
||||
app_state: &Arc<AppState>,
|
||||
|
@ -4075,6 +4077,36 @@ async fn join_channel_internal(
|
|||
return Some(join_remote_project(project, host, app_state.clone(), cx));
|
||||
}
|
||||
|
||||
// if you are the first to join a channel, share your project
|
||||
if room.remote_participants().len() == 0 && !room.local_participant_is_guest() {
|
||||
if let Some(workspace) = requesting_window {
|
||||
let project = workspace.update(cx, |workspace, cx| {
|
||||
if !CallSettings::get_global(cx).share_on_join {
|
||||
return None;
|
||||
}
|
||||
let project = workspace.project.read(cx);
|
||||
if project.is_local()
|
||||
&& project.visible_worktrees(cx).any(|tree| {
|
||||
tree.read(cx)
|
||||
.root_entry()
|
||||
.map_or(false, |entry| entry.is_dir())
|
||||
})
|
||||
{
|
||||
Some(workspace.project.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
if let Ok(Some(project)) = project {
|
||||
return Some(cx.spawn(|room, mut cx| async move {
|
||||
room.update(&mut cx, |room, cx| room.share_project(project, cx))?
|
||||
.await?;
|
||||
Ok(())
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
})?;
|
||||
if let Some(task) = task {
|
||||
|
@ -4117,6 +4149,12 @@ pub fn join_channel(
|
|||
})?
|
||||
.await?;
|
||||
|
||||
if result.is_ok() {
|
||||
cx.update(|cx| {
|
||||
cx.dispatch_action(&OpenChannelNotes);
|
||||
}).log_err();
|
||||
}
|
||||
|
||||
active_window = Some(window_handle);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue