From ae87961a773501decc3b02dc084fbc102c050540 Mon Sep 17 00:00:00 2001 From: Julia Date: Mon, 20 Feb 2023 14:18:04 -0500 Subject: [PATCH] Close contacts popover when call ends Co-Authored-By: Nathan Sobo --- crates/collab_ui/src/collab_titlebar_item.rs | 29 ++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index b450ee4a2727de5af8ecae9931748ca7393dd067..9893a047b04b022a982ea006020cffe7d3de331b 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -140,7 +140,7 @@ impl CollabTitlebarItem { let active_call = ActiveCall::global(cx); let mut subscriptions = Vec::new(); subscriptions.push(cx.observe(workspace, |_, _, cx| cx.notify())); - subscriptions.push(cx.observe(&active_call, |_, _, cx| cx.notify())); + subscriptions.push(cx.observe(&active_call, |this, _, cx| this.active_call_changed(cx))); subscriptions.push(cx.observe_window_activation(|this, active, cx| { this.window_activation_changed(active, cx) })); @@ -191,6 +191,13 @@ impl CollabTitlebarItem { } } + fn active_call_changed(&mut self, cx: &mut ViewContext) { + if ActiveCall::global(cx).read(cx).room().is_none() { + self.contacts_popover = None; + } + cx.notify(); + } + fn share_project(&mut self, _: &ShareProject, cx: &mut ViewContext) { if let Some(workspace) = self.workspace.upgrade(cx) { let active_call = ActiveCall::global(cx); @@ -397,7 +404,11 @@ impl CollabTitlebarItem { .boxed(), ) .with_children(badge) - .with_children(self.contacts_popover_host(ContactsPopoverSide::Left, titlebar, cx)) + .with_children(self.render_contacts_popover_host( + ContactsPopoverSide::Left, + titlebar, + cx, + )) .boxed() } @@ -499,7 +510,11 @@ impl CollabTitlebarItem { ) .boxed(), ) - .with_children(self.contacts_popover_host(ContactsPopoverSide::Right, titlebar, cx)) + .with_children(self.render_contacts_popover_host( + ContactsPopoverSide::Right, + titlebar, + cx, + )) .aligned() .contained() .with_margin_left(theme.workspace.titlebar.avatar_margin) @@ -543,7 +558,11 @@ impl CollabTitlebarItem { ) .boxed(), ) - .with_children(self.contacts_popover_host(ContactsPopoverSide::Right, titlebar, cx)) + .with_children(self.render_contacts_popover_host( + ContactsPopoverSide::Right, + titlebar, + cx, + )) .aligned() .contained() .with_margin_left(theme.workspace.titlebar.avatar_margin) @@ -551,7 +570,7 @@ impl CollabTitlebarItem { .boxed() } - fn contacts_popover_host<'a>( + fn render_contacts_popover_host<'a>( &'a self, side: ContactsPopoverSide, theme: &'a theme::Titlebar,