diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index fffe90716e..9eee6c9075 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -19,7 +19,7 @@ use serde::Deserialize; use settings::Settings; use std::{mem, sync::Arc}; use theme::IconButton; -use workspace::{OpenSharedScreen, Workspace}; +use workspace::Workspace; impl_actions!(contact_list, [RemoveContact, RespondToContactRequest]); impl_internal_actions!(contact_list, [ToggleExpanded, Call]); @@ -433,7 +433,11 @@ impl ContactList { } } ContactEntry::ParticipantScreen { peer_id, .. } => { - cx.dispatch_action(OpenSharedScreen { peer_id: *peer_id }); + if let Some(workspace) = self.workspace.upgrade(cx) { + workspace.update(cx, |workspace, cx| { + workspace.open_shared_screen(*peer_id, cx) + }); + } } _ => {} } @@ -899,6 +903,8 @@ impl ContactList { theme: &theme::ContactList, cx: &mut ViewContext, ) -> AnyElement { + enum OpenSharedScreen {} + let font_cache = cx.font_cache(); let host_avatar_height = theme .contact_avatar @@ -979,8 +985,12 @@ impl ContactList { }, ) .with_cursor_style(CursorStyle::PointingHand) - .on_click(MouseButton::Left, move |_, _, cx| { - cx.dispatch_action(OpenSharedScreen { peer_id }); + .on_click(MouseButton::Left, move |_, this, cx| { + if let Some(workspace) = this.workspace.upgrade(cx) { + workspace.update(cx, |workspace, cx| { + workspace.open_shared_screen(peer_id, cx) + }); + } }) .into_any() } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 3dbb94f4b8..98d8b59d4d 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -134,11 +134,6 @@ pub struct OpenPaths { #[derive(Clone, Deserialize, PartialEq)] pub struct ActivatePane(pub usize); -#[derive(Clone, PartialEq)] -pub struct OpenSharedScreen { - pub peer_id: PeerId, -} - #[derive(Clone, PartialEq)] pub struct SplitWithItem { pane_to_split: WeakViewHandle, @@ -209,7 +204,6 @@ pub type WorkspaceId = i64; impl_internal_actions!( workspace, [ - OpenSharedScreen, RemoveWorktreeFromProject, SplitWithItem, SplitWithProjectEntry, @@ -290,7 +284,6 @@ pub fn init(app_state: Arc, cx: &mut AppContext) { cx.add_async_action(Workspace::close); cx.add_global_action(Workspace::close_global); cx.add_async_action(Workspace::save_all); - cx.add_action(Workspace::open_shared_screen); cx.add_action(Workspace::add_folder_to_project); cx.add_action(Workspace::remove_folder_from_project); cx.add_action( @@ -1606,10 +1599,8 @@ impl Workspace { item } - pub fn open_shared_screen(&mut self, action: &OpenSharedScreen, cx: &mut ViewContext) { - if let Some(shared_screen) = - self.shared_screen_for_peer(action.peer_id, &self.active_pane, cx) - { + pub fn open_shared_screen(&mut self, peer_id: PeerId, cx: &mut ViewContext) { + if let Some(shared_screen) = self.shared_screen_for_peer(peer_id, &self.active_pane, cx) { let pane = self.active_pane.clone(); Pane::add_item(self, &pane, Box::new(shared_screen), false, true, None, cx); }