From bf0a04ab50f8a11071e67ddb0d2db4085d91d6cc Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 11 Oct 2022 11:01:38 +0200 Subject: [PATCH] Dismiss popover when contact finder is unfocused --- crates/collab_ui/src/contacts_popover.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/crates/collab_ui/src/contacts_popover.rs b/crates/collab_ui/src/contacts_popover.rs index b9b1d254b6..0758cf735d 100644 --- a/crates/collab_ui/src/contacts_popover.rs +++ b/crates/collab_ui/src/contacts_popover.rs @@ -27,7 +27,6 @@ pub struct ContactsPopover { project: ModelHandle, user_store: ModelHandle, _subscription: Option, - _window_subscription: gpui::Subscription, } impl ContactsPopover { @@ -43,18 +42,11 @@ impl ContactsPopover { project, user_store, _subscription: None, - _window_subscription: cx.observe_window_activation(Self::window_activation_changed), }; this.show_contact_list(cx); this } - fn window_activation_changed(&mut self, active: bool, cx: &mut ViewContext) { - if !active { - cx.emit(Event::Dismissed); - } - } - fn toggle_contact_finder(&mut self, _: &ToggleContactFinder, cx: &mut ViewContext) { match &self.child { Child::ContactList(_) => self.show_contact_finder(cx), @@ -65,8 +57,8 @@ impl ContactsPopover { fn show_contact_finder(&mut self, cx: &mut ViewContext) { let child = cx.add_view(|cx| ContactFinder::new(self.user_store.clone(), cx)); cx.focus(&child); - self._subscription = Some(cx.subscribe(&child, |this, _, event, cx| match event { - crate::contact_finder::Event::Dismissed => this.show_contact_list(cx), + self._subscription = Some(cx.subscribe(&child, |_, _, event, cx| match event { + crate::contact_finder::Event::Dismissed => cx.emit(Event::Dismissed), })); self.child = Child::ContactFinder(child); cx.notify();