mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-28 21:32:39 +00:00
Ensure chat opens when guests join shared projects
This was broken because the panel was created before being added to a dock. Invert the control order and add `starts_open()` to the Panel trait.
This commit is contained in:
parent
291f353085
commit
2a11c22760
4 changed files with 22 additions and 30 deletions
|
@ -132,14 +132,6 @@ impl ChatPanel {
|
||||||
{
|
{
|
||||||
this.select_channel(channel_id, None, cx)
|
this.select_channel(channel_id, None, cx)
|
||||||
.detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
|
|
||||||
if ActiveCall::global(cx)
|
|
||||||
.read(cx)
|
|
||||||
.room()
|
|
||||||
.is_some_and(|room| room.read(cx).contains_guests())
|
|
||||||
{
|
|
||||||
cx.emit(PanelEvent::Activate)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.subscriptions.push(cx.subscribe(
|
this.subscriptions.push(cx.subscribe(
|
||||||
|
@ -665,6 +657,13 @@ impl Panel for ChatPanel {
|
||||||
fn toggle_action(&self) -> Box<dyn gpui::Action> {
|
fn toggle_action(&self) -> Box<dyn gpui::Action> {
|
||||||
Box::new(ToggleFocus)
|
Box::new(ToggleFocus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn starts_open(&self, cx: &WindowContext) -> bool {
|
||||||
|
ActiveCall::global(cx)
|
||||||
|
.read(cx)
|
||||||
|
.room()
|
||||||
|
.is_some_and(|room| room.read(cx).contains_guests())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventEmitter<PanelEvent> for ChatPanel {}
|
impl EventEmitter<PanelEvent> for ChatPanel {}
|
||||||
|
|
|
@ -58,7 +58,6 @@ pub struct ProjectPanel {
|
||||||
workspace: WeakView<Workspace>,
|
workspace: WeakView<Workspace>,
|
||||||
width: Option<Pixels>,
|
width: Option<Pixels>,
|
||||||
pending_serialization: Task<Option<()>>,
|
pending_serialization: Task<Option<()>>,
|
||||||
was_deserialized: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
@ -244,7 +243,6 @@ impl ProjectPanel {
|
||||||
workspace: workspace.weak_handle(),
|
workspace: workspace.weak_handle(),
|
||||||
width: None,
|
width: None,
|
||||||
pending_serialization: Task::ready(None),
|
pending_serialization: Task::ready(None),
|
||||||
was_deserialized: false,
|
|
||||||
};
|
};
|
||||||
this.update_visible_entries(None, cx);
|
this.update_visible_entries(None, cx);
|
||||||
|
|
||||||
|
@ -324,7 +322,6 @@ impl ProjectPanel {
|
||||||
if let Some(serialized_panel) = serialized_panel {
|
if let Some(serialized_panel) = serialized_panel {
|
||||||
panel.update(cx, |panel, cx| {
|
panel.update(cx, |panel, cx| {
|
||||||
panel.width = serialized_panel.width;
|
panel.width = serialized_panel.width;
|
||||||
panel.was_deserialized = true;
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1460,9 +1457,6 @@ impl ProjectPanel {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn was_deserialized(&self) -> bool {
|
|
||||||
self.was_deserialized
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ProjectPanel {
|
impl Render for ProjectPanel {
|
||||||
|
@ -1637,6 +1631,14 @@ impl Panel for ProjectPanel {
|
||||||
fn persistent_name() -> &'static str {
|
fn persistent_name() -> &'static str {
|
||||||
"Project Panel"
|
"Project Panel"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn starts_open(&self, cx: &WindowContext) -> bool {
|
||||||
|
self.project.read(cx).visible_worktrees(cx).any(|tree| {
|
||||||
|
tree.read(cx)
|
||||||
|
.root_entry()
|
||||||
|
.map_or(false, |entry| entry.is_dir())
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FocusableView for ProjectPanel {
|
impl FocusableView for ProjectPanel {
|
||||||
|
|
|
@ -38,6 +38,9 @@ pub trait Panel: FocusableView + EventEmitter<PanelEvent> {
|
||||||
fn is_zoomed(&self, _cx: &WindowContext) -> bool {
|
fn is_zoomed(&self, _cx: &WindowContext) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
fn starts_open(&self, _cx: &WindowContext) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
fn set_zoomed(&mut self, _zoomed: bool, _cx: &mut ViewContext<Self>) {}
|
fn set_zoomed(&mut self, _zoomed: bool, _cx: &mut ViewContext<Self>) {}
|
||||||
fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
|
fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
|
||||||
}
|
}
|
||||||
|
@ -414,7 +417,7 @@ impl Dock {
|
||||||
let name = panel.persistent_name().to_string();
|
let name = panel.persistent_name().to_string();
|
||||||
|
|
||||||
self.panel_entries.push(PanelEntry {
|
self.panel_entries.push(PanelEntry {
|
||||||
panel: Arc::new(panel),
|
panel: Arc::new(panel.clone()),
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
});
|
});
|
||||||
if let Some(serialized) = self.serialized_dock.clone() {
|
if let Some(serialized) = self.serialized_dock.clone() {
|
||||||
|
@ -429,6 +432,9 @@ impl Dock {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if panel.read(cx).starts_open(cx) {
|
||||||
|
self.activate_panel(self.panel_entries.len() - 1, cx);
|
||||||
|
self.set_open(true, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.notify()
|
cx.notify()
|
||||||
|
|
|
@ -179,27 +179,12 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
workspace_handle.update(&mut cx, |workspace, cx| {
|
workspace_handle.update(&mut cx, |workspace, cx| {
|
||||||
let was_deserialized = project_panel.read(cx).was_deserialized();
|
|
||||||
workspace.add_panel(project_panel, cx);
|
workspace.add_panel(project_panel, cx);
|
||||||
workspace.add_panel(terminal_panel, cx);
|
workspace.add_panel(terminal_panel, cx);
|
||||||
workspace.add_panel(assistant_panel, cx);
|
workspace.add_panel(assistant_panel, cx);
|
||||||
workspace.add_panel(channels_panel, cx);
|
workspace.add_panel(channels_panel, cx);
|
||||||
workspace.add_panel(chat_panel, cx);
|
workspace.add_panel(chat_panel, cx);
|
||||||
workspace.add_panel(notification_panel, cx);
|
workspace.add_panel(notification_panel, cx);
|
||||||
|
|
||||||
if !was_deserialized
|
|
||||||
&& workspace
|
|
||||||
.project()
|
|
||||||
.read(cx)
|
|
||||||
.visible_worktrees(cx)
|
|
||||||
.any(|tree| {
|
|
||||||
tree.read(cx)
|
|
||||||
.root_entry()
|
|
||||||
.map_or(false, |entry| entry.is_dir())
|
|
||||||
})
|
|
||||||
{
|
|
||||||
workspace.open_panel::<ProjectPanel>(cx);
|
|
||||||
}
|
|
||||||
cx.focus_self();
|
cx.focus_self();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue