From 8f8880369511ef5d0c781766639637ed89e5dceb Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 17 May 2022 15:35:57 +0200 Subject: [PATCH] Automatically follow host when joining a project --- crates/workspace/src/waiting_room.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/workspace/src/waiting_room.rs b/crates/workspace/src/waiting_room.rs index a8b717abb9f89f57639c38d5f864adfd69d7893a..fef7bf2e4332ebfe94c96bafd6fefd3706cd7f13 100644 --- a/crates/workspace/src/waiting_room.rs +++ b/crates/workspace/src/waiting_room.rs @@ -1,6 +1,6 @@ use crate::{ sidebar::{Side, ToggleSidebarItem}, - AppState, + AppState, ToggleFollow, }; use anyhow::Result; use client::{proto, Client, Contact}; @@ -96,8 +96,11 @@ impl WaitingRoom { match project { Ok(project) => { cx.replace_root_view(|cx| { - let mut workspace = - (app_state.build_workspace)(project, &app_state, cx); + let mut workspace = (app_state.build_workspace)( + project.clone(), + &app_state, + cx, + ); workspace.toggle_sidebar_item( &ToggleSidebarItem { side: Side::Left, @@ -105,6 +108,18 @@ impl WaitingRoom { }, cx, ); + if let Some((host_peer_id, _)) = project + .read(cx) + .collaborators() + .iter() + .find(|(_, collaborator)| collaborator.replica_id == 0) + { + if let Some(follow) = workspace + .toggle_follow(&ToggleFollow(*host_peer_id), cx) + { + follow.detach_and_log_err(cx); + } + } workspace }); }