From e900ea20b7cfbefb75038ed0e2f1def312fc3733 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 12 Oct 2023 16:12:09 -0400 Subject: [PATCH] Fix toggling of left panel --- crates/ui2/src/components/workspace.rs | 33 +++----------------------- 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/crates/ui2/src/components/workspace.rs b/crates/ui2/src/components/workspace.rs index 256e262e98..21feff873f 100644 --- a/crates/ui2/src/components/workspace.rs +++ b/crates/ui2/src/components/workspace.rs @@ -13,8 +13,6 @@ use crate::{ }; pub struct WorkspaceState { - pub show_project_panel: Arc, - pub show_collab_panel: Arc, pub show_chat_panel: Arc, pub show_assistant_panel: Arc, pub show_terminal: Arc, @@ -30,26 +28,6 @@ impl WorkspaceState { .unwrap(); } - pub fn is_project_panel_open(&self) -> bool { - self.show_project_panel.load(Ordering::SeqCst) - } - - pub fn toggle_project_panel(&self) { - Self::toggle_value(&self.show_project_panel); - - self.show_collab_panel.store(false, Ordering::SeqCst); - } - - pub fn is_collab_panel_open(&self) -> bool { - self.show_collab_panel.load(Ordering::SeqCst) - } - - pub fn toggle_collab_panel(&self) { - Self::toggle_value(&self.show_collab_panel); - - self.show_project_panel.store(false, Ordering::SeqCst); - } - pub fn is_terminal_open(&self) -> bool { self.show_terminal.load(Ordering::SeqCst) } @@ -93,8 +71,6 @@ static WORKSPACE_STATE: OnceLock = OnceLock::new(); pub fn get_workspace_state() -> &'static WorkspaceState { let state = WORKSPACE_STATE.get_or_init(|| WorkspaceState { - show_project_panel: Arc::new(AtomicBool::new(true)), - show_collab_panel: Arc::new(AtomicBool::new(false)), show_chat_panel: Arc::new(AtomicBool::new(true)), show_assistant_panel: Arc::new(AtomicBool::new(false)), show_terminal: Arc::new(AtomicBool::new(true)), @@ -104,7 +80,6 @@ pub fn get_workspace_state() -> &'static WorkspaceState { state } -// #[derive(Element)] #[derive(Clone)] pub struct Workspace { show_project_panel: bool, @@ -132,7 +107,7 @@ impl Workspace { } pub fn is_project_panel_open(&self) -> bool { - dbg!(self.show_project_panel) + self.show_project_panel } pub fn toggle_project_panel(&mut self, cx: &mut ViewContext) { @@ -140,8 +115,6 @@ impl Workspace { self.show_collab_panel = false; - dbg!(self.show_project_panel); - cx.notify(); } @@ -235,7 +208,7 @@ impl Workspace { .side(PanelSide::Left) .child(ProjectPanel::new(ScrollState::default())), ) - .filter(|_| workspace_state.is_project_panel_open()), + .filter(|_| self.is_project_panel_open()), ) .children( Some( @@ -243,7 +216,7 @@ impl Workspace { .child(CollabPanel::new(ScrollState::default())) .side(PanelSide::Left), ) - .filter(|_| workspace_state.is_collab_panel_open()), + .filter(|_| self.is_collab_panel_open()), ) .child( v_stack()