mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-28 21:32:39 +00:00
Make App::notify_view
private
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
8c7f821d14
commit
a860a6cd62
2 changed files with 9 additions and 8 deletions
|
@ -1112,21 +1112,21 @@ impl AppContext {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn notify_model(&mut self, model_id: usize) {
|
fn notify_model(&mut self, model_id: usize) {
|
||||||
if self.pending_notifications.insert(model_id) {
|
if self.pending_notifications.insert(model_id) {
|
||||||
self.pending_effects
|
self.pending_effects
|
||||||
.push_back(Effect::ModelNotification { model_id });
|
.push_back(Effect::ModelNotification { model_id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn notify_view(&mut self, window_id: usize, view_id: usize) {
|
fn notify_view(&mut self, window_id: usize, view_id: usize) {
|
||||||
if self.pending_notifications.insert(view_id) {
|
if self.pending_notifications.insert(view_id) {
|
||||||
self.pending_effects
|
self.pending_effects
|
||||||
.push_back(Effect::ViewNotification { window_id, view_id });
|
.push_back(Effect::ViewNotification { window_id, view_id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn notify_global(&mut self, type_id: TypeId) {
|
fn notify_global(&mut self, type_id: TypeId) {
|
||||||
if self.pending_global_notifications.insert(type_id) {
|
if self.pending_global_notifications.insert(type_id) {
|
||||||
self.pending_effects
|
self.pending_effects
|
||||||
.push_back(Effect::GlobalNotification { type_id });
|
.push_back(Effect::GlobalNotification { type_id });
|
||||||
|
|
|
@ -15,6 +15,7 @@ use std::{
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
use util::ResultExt;
|
||||||
|
|
||||||
const DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(500);
|
const DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(500);
|
||||||
|
|
||||||
|
@ -94,20 +95,20 @@ impl<V: View> Tooltip<V> {
|
||||||
let child = MouseEventHandler::<MouseEventHandlerState<Tag>, _>::new(id, cx, |_, _| child)
|
let child = MouseEventHandler::<MouseEventHandlerState<Tag>, _>::new(id, cx, |_, _| child)
|
||||||
.on_hover(move |e, _, cx| {
|
.on_hover(move |e, _, cx| {
|
||||||
let position = e.position;
|
let position = e.position;
|
||||||
let window_id = cx.window_id();
|
|
||||||
let view_id = cx.view_id();
|
|
||||||
if e.started {
|
if e.started {
|
||||||
if !state.visible.get() {
|
if !state.visible.get() {
|
||||||
state.position.set(position);
|
state.position.set(position);
|
||||||
|
|
||||||
let mut debounce = state.debounce.borrow_mut();
|
let mut debounce = state.debounce.borrow_mut();
|
||||||
if debounce.is_none() {
|
if debounce.is_none() {
|
||||||
*debounce = Some(cx.spawn({
|
*debounce = Some(cx.spawn_weak({
|
||||||
let state = state.clone();
|
let state = state.clone();
|
||||||
|_, mut cx| async move {
|
|view, mut cx| async move {
|
||||||
cx.background().timer(DEBOUNCE_TIMEOUT).await;
|
cx.background().timer(DEBOUNCE_TIMEOUT).await;
|
||||||
state.visible.set(true);
|
state.visible.set(true);
|
||||||
cx.update(|cx| cx.notify_view(window_id, view_id));
|
if let Some(view) = view.upgrade(&cx) {
|
||||||
|
view.update(&mut cx, |_, cx| cx.notify()).log_err();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue