mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
Dismiss popover when contact finder is unfocused
This commit is contained in:
parent
bf488f2027
commit
bf0a04ab50
1 changed files with 2 additions and 10 deletions
|
@ -27,7 +27,6 @@ pub struct ContactsPopover {
|
||||||
project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
user_store: ModelHandle<UserStore>,
|
user_store: ModelHandle<UserStore>,
|
||||||
_subscription: Option<gpui::Subscription>,
|
_subscription: Option<gpui::Subscription>,
|
||||||
_window_subscription: gpui::Subscription,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContactsPopover {
|
impl ContactsPopover {
|
||||||
|
@ -43,18 +42,11 @@ impl ContactsPopover {
|
||||||
project,
|
project,
|
||||||
user_store,
|
user_store,
|
||||||
_subscription: None,
|
_subscription: None,
|
||||||
_window_subscription: cx.observe_window_activation(Self::window_activation_changed),
|
|
||||||
};
|
};
|
||||||
this.show_contact_list(cx);
|
this.show_contact_list(cx);
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window_activation_changed(&mut self, active: bool, cx: &mut ViewContext<Self>) {
|
|
||||||
if !active {
|
|
||||||
cx.emit(Event::Dismissed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn toggle_contact_finder(&mut self, _: &ToggleContactFinder, cx: &mut ViewContext<Self>) {
|
fn toggle_contact_finder(&mut self, _: &ToggleContactFinder, cx: &mut ViewContext<Self>) {
|
||||||
match &self.child {
|
match &self.child {
|
||||||
Child::ContactList(_) => self.show_contact_finder(cx),
|
Child::ContactList(_) => self.show_contact_finder(cx),
|
||||||
|
@ -65,8 +57,8 @@ impl ContactsPopover {
|
||||||
fn show_contact_finder(&mut self, cx: &mut ViewContext<ContactsPopover>) {
|
fn show_contact_finder(&mut self, cx: &mut ViewContext<ContactsPopover>) {
|
||||||
let child = cx.add_view(|cx| ContactFinder::new(self.user_store.clone(), cx));
|
let child = cx.add_view(|cx| ContactFinder::new(self.user_store.clone(), cx));
|
||||||
cx.focus(&child);
|
cx.focus(&child);
|
||||||
self._subscription = Some(cx.subscribe(&child, |this, _, event, cx| match event {
|
self._subscription = Some(cx.subscribe(&child, |_, _, event, cx| match event {
|
||||||
crate::contact_finder::Event::Dismissed => this.show_contact_list(cx),
|
crate::contact_finder::Event::Dismissed => cx.emit(Event::Dismissed),
|
||||||
}));
|
}));
|
||||||
self.child = Child::ContactFinder(child);
|
self.child = Child::ContactFinder(child);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|
Loading…
Reference in a new issue