Remove OpenSharedScreen internal action

This commit is contained in:
Antonio Scandurra 2023-04-28 12:09:34 +02:00
parent d953729233
commit 71a4bc7905
2 changed files with 16 additions and 15 deletions

View file

@ -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<Self>,
) -> AnyElement<Self> {
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()
}

View file

@ -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<Pane>,
@ -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<AppState>, 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<Self>) {
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<Self>) {
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);
}