From e6576b32b2e49def177bb048c9ce1241ea9613d5 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 16 May 2022 15:37:29 +0200 Subject: [PATCH] Don't show "they won't know if you decline" when request is accepted --- crates/contacts_panel/src/contact_notification.rs | 2 ++ .../contacts_panel/src/join_project_notification.rs | 1 + crates/contacts_panel/src/notifications.rs | 13 +++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/contacts_panel/src/contact_notification.rs b/crates/contacts_panel/src/contact_notification.rs index 7df0f7cad9..2d408da0c2 100644 --- a/crates/contacts_panel/src/contact_notification.rs +++ b/crates/contacts_panel/src/contact_notification.rs @@ -45,6 +45,7 @@ impl View for ContactNotification { ContactEventKind::Requested => render_user_notification( self.event.user.clone(), "wants to add you as a contact", + Some("They won't know if you decline."), RespondToContactRequest { user_id: self.event.user.id, accept: false, @@ -70,6 +71,7 @@ impl View for ContactNotification { ContactEventKind::Accepted => render_user_notification( self.event.user.clone(), "accepted your contact request", + None, Dismiss(self.event.user.id), vec![], cx, diff --git a/crates/contacts_panel/src/join_project_notification.rs b/crates/contacts_panel/src/join_project_notification.rs index e3cd1c6c9e..67ec59a740 100644 --- a/crates/contacts_panel/src/join_project_notification.rs +++ b/crates/contacts_panel/src/join_project_notification.rs @@ -57,6 +57,7 @@ impl View for JoinProjectNotification { render_user_notification( self.user.clone(), "wants to join your project", + Some("They won't know if you decline."), Decline, vec![("Decline", Box::new(Decline)), ("Accept", Box::new(Accept))], cx, diff --git a/crates/contacts_panel/src/notifications.rs b/crates/contacts_panel/src/notifications.rs index 21eac2a3c4..555d8962d3 100644 --- a/crates/contacts_panel/src/notifications.rs +++ b/crates/contacts_panel/src/notifications.rs @@ -13,7 +13,8 @@ enum Button {} pub fn render_user_notification( user: Arc, - message: &str, + title: &str, + body: Option<&str>, dismiss_action: A, buttons: Vec<(&'static str, Box)>, cx: &mut RenderContext, @@ -39,7 +40,7 @@ pub fn render_user_notification( })) .with_child( Text::new( - format!("{} {}", user.github_login, message), + format!("{} {}", user.github_login, title), theme.header_message.text.clone(), ) .contained() @@ -74,15 +75,15 @@ pub fn render_user_notification( ) .named("contact notification header"), ) - .with_child( + .with_children(body.map(|body| { Label::new( - "They won't know if you decline.".to_string(), + body.to_string(), theme.body_message.text.clone(), ) .contained() .with_style(theme.body_message.container) - .boxed(), - ) + .boxed() + })) .with_children(if buttons.is_empty() { None } else {