From 29413bc72c6a5b1dbb68ebdd7ce05ff6ca4c9571 Mon Sep 17 00:00:00 2001 From: Julia Date: Tue, 12 Dec 2023 17:47:12 -0500 Subject: [PATCH] Fix defer handle double lease Co-Authored-By: Conrad Irwin --- crates/collab_ui2/src/notification_panel.rs | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/crates/collab_ui2/src/notification_panel.rs b/crates/collab_ui2/src/notification_panel.rs index b347614830..35288e810d 100644 --- a/crates/collab_ui2/src/notification_panel.rs +++ b/crates/collab_ui2/src/notification_panel.rs @@ -6,9 +6,9 @@ use collections::HashMap; use db::kvp::KEY_VALUE_STORE; use futures::StreamExt; use gpui::{ - actions, div, list, px, serde_json, AnyElement, AppContext, AsyncWindowContext, DismissEvent, - Div, Element, EventEmitter, FocusHandle, FocusableView, InteractiveElement, IntoElement, - ListAlignment, ListScrollEvent, ListState, Model, ParentElement, Render, Stateful, + actions, div, list, px, serde_json, AnyElement, AppContext, AsyncWindowContext, CursorStyle, + DismissEvent, Div, Element, EventEmitter, FocusHandle, FocusableView, InteractiveElement, + IntoElement, ListAlignment, ListScrollEvent, ListState, Model, ParentElement, Render, Stateful, StatefulInteractiveElement, Styled, Task, View, ViewContext, VisualContext, WeakView, WindowContext, }; @@ -19,10 +19,7 @@ use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsStore}; use std::{sync::Arc, time::Duration}; use time::{OffsetDateTime, UtcOffset}; -use ui::{ - h_stack, v_stack, Avatar, Button, ButtonLike, Clickable, Disableable, Icon, IconButton, - IconElement, Label, -}; +use ui::{h_stack, v_stack, Avatar, Button, Clickable, Icon, IconButton, IconElement, Label}; use util::{ResultExt, TryFutureExt}; use workspace::{ dock::{DockPosition, Panel, PanelEvent}, @@ -287,9 +284,13 @@ impl NotificationPanel { ), ), ) - .on_click({ - let notification = notification.clone(); - cx.listener(move |this, _, cx| this.did_click_notification(¬ification, cx)) + .when(can_navigate, |el| { + el.cursor(CursorStyle::PointingHand).on_click({ + let notification = notification.clone(); + cx.listener(move |this, _, cx| { + this.did_click_notification(¬ification, cx) + }) + }) }) .into_any(), ) @@ -405,7 +406,7 @@ impl NotificationPanel { } = notification.clone() { if let Some(workspace) = self.workspace.upgrade() { - cx.defer(move |_, cx| { + cx.window_context().defer(move |cx| { workspace.update(cx, |workspace, cx| { if let Some(panel) = workspace.focus_panel::(cx) { panel.update(cx, |panel, cx| { @@ -647,7 +648,7 @@ impl NotificationToast { fn focus_notification_panel(&self, cx: &mut ViewContext) { let workspace = self.workspace.clone(); let notification_id = self.notification_id; - cx.defer(move |_, cx| { + cx.window_context().defer(move |cx| { workspace .update(cx, |workspace, cx| { if let Some(panel) = workspace.focus_panel::(cx) {