Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make `App::notify_view` private
Antonio Scandurraa860a6cd62ae
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rsindex 9ef2cf40207..762837c478a 100644--- a/crates/gpui/src/app.rs+++ b/crates/gpui/src/app.rs@@ -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) {self.pending_effects.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) {self.pending_effects.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) {self.pending_effects.push_back(Effect::GlobalNotification { type_id });diff --git a/crates/gpui/src/elements/tooltip.rs b/crates/gpui/src/elements/tooltip.rsindex 6d2d8d2cc4c..d30c0994008 100644--- a/crates/gpui/src/elements/tooltip.rs+++ b/crates/gpui/src/elements/tooltip.rs@@ -15,6 +15,7 @@ use std::{rc::Rc,time::Duration,};+use util::ResultExt;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).on_hover(move |e, _, cx| {let position = e.position;- let window_id = cx.window_id();- let view_id = cx.view_id();if e.started {if !state.visible.get() {state.position.set(position);let mut debounce = state.debounce.borrow_mut();if debounce.is_none() {- *debounce = Some(cx.spawn({+ *debounce = Some(cx.spawn_weak({let state = state.clone();- |_, mut cx| async move {+ |view, mut cx| async move {cx.background().timer(DEBOUNCE_TIMEOUT).await;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();+ }}}));}