Don't show "they won't know if you decline" when request is accepted

This commit is contained in:
Antonio Scandurra 2022-05-16 15:37:29 +02:00
parent c2973f33c2
commit e6576b32b2
3 changed files with 10 additions and 6 deletions

View file

@ -45,6 +45,7 @@ impl View for ContactNotification {
ContactEventKind::Requested => render_user_notification( ContactEventKind::Requested => render_user_notification(
self.event.user.clone(), self.event.user.clone(),
"wants to add you as a contact", "wants to add you as a contact",
Some("They won't know if you decline."),
RespondToContactRequest { RespondToContactRequest {
user_id: self.event.user.id, user_id: self.event.user.id,
accept: false, accept: false,
@ -70,6 +71,7 @@ impl View for ContactNotification {
ContactEventKind::Accepted => render_user_notification( ContactEventKind::Accepted => render_user_notification(
self.event.user.clone(), self.event.user.clone(),
"accepted your contact request", "accepted your contact request",
None,
Dismiss(self.event.user.id), Dismiss(self.event.user.id),
vec![], vec![],
cx, cx,

View file

@ -57,6 +57,7 @@ impl View for JoinProjectNotification {
render_user_notification( render_user_notification(
self.user.clone(), self.user.clone(),
"wants to join your project", "wants to join your project",
Some("They won't know if you decline."),
Decline, Decline,
vec![("Decline", Box::new(Decline)), ("Accept", Box::new(Accept))], vec![("Decline", Box::new(Decline)), ("Accept", Box::new(Accept))],
cx, cx,

View file

@ -13,7 +13,8 @@ enum Button {}
pub fn render_user_notification<V: View, A: Action + Clone>( pub fn render_user_notification<V: View, A: Action + Clone>(
user: Arc<User>, user: Arc<User>,
message: &str, title: &str,
body: Option<&str>,
dismiss_action: A, dismiss_action: A,
buttons: Vec<(&'static str, Box<dyn Action>)>, buttons: Vec<(&'static str, Box<dyn Action>)>,
cx: &mut RenderContext<V>, cx: &mut RenderContext<V>,
@ -39,7 +40,7 @@ pub fn render_user_notification<V: View, A: Action + Clone>(
})) }))
.with_child( .with_child(
Text::new( Text::new(
format!("{} {}", user.github_login, message), format!("{} {}", user.github_login, title),
theme.header_message.text.clone(), theme.header_message.text.clone(),
) )
.contained() .contained()
@ -74,15 +75,15 @@ pub fn render_user_notification<V: View, A: Action + Clone>(
) )
.named("contact notification header"), .named("contact notification header"),
) )
.with_child( .with_children(body.map(|body| {
Label::new( Label::new(
"They won't know if you decline.".to_string(), body.to_string(),
theme.body_message.text.clone(), theme.body_message.text.clone(),
) )
.contained() .contained()
.with_style(theme.body_message.container) .with_style(theme.body_message.container)
.boxed(), .boxed()
) }))
.with_children(if buttons.is_empty() { .with_children(if buttons.is_empty() {
None None
} else { } else {