From c18f1b6246e1b1c963db845fe4321472adb39d93 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Sat, 11 Mar 2023 19:28:35 -0500 Subject: [PATCH] Mention username of user in prompt when removing a contact --- crates/collab_ui/src/contact_list.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index 38444f6f12..aae8614a40 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -141,7 +141,10 @@ impl PartialEq for ContactEntry { pub struct RequestContact(pub u64); #[derive(Clone, Deserialize, PartialEq)] -pub struct RemoveContact(pub u64); +pub struct RemoveContact<'a> { + user_id: u64, + github_login: &'a str, +} #[derive(Clone, Deserialize, PartialEq)] pub struct RespondToContactRequest { @@ -305,10 +308,14 @@ impl ContactList { } fn remove_contact(&mut self, request: &RemoveContact, cx: &mut ViewContext) { - let user_id = request.0; + let user_id = request.user_id; + let github_login = &request.github_login; let user_store = self.user_store.clone(); - let prompt_message = "Are you sure you want to remove this contact?"; - let mut answer = cx.prompt(PromptLevel::Warning, prompt_message, &["Remove", "Cancel"]); + let prompt_message = format!( + "Are you sure you want to remove \"{}\" from your contacts?", + github_login + ); + let mut answer = cx.prompt(PromptLevel::Warning, &prompt_message, &["Remove", "Cancel"]); cx.spawn(|_, mut cx| async move { if answer.next().await == Some(0) { user_store @@ -1067,6 +1074,7 @@ impl ContactList { let online = contact.online; let busy = contact.busy || calling; let user_id = contact.user.id; + let github_login = &contact.user.github_login; let initial_project = project.clone(); let mut element = MouseEventHandler::::new(contact.user.id as usize, cx, |_, cx| { @@ -1127,7 +1135,10 @@ impl ContactList { .with_padding(Padding::uniform(2.)) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, cx| { - cx.dispatch_action(RemoveContact(user_id)) + cx.dispatch_action(RemoveContact { + user_id, + github_login, + }) }) .flex_float() .boxed(), @@ -1203,6 +1214,7 @@ impl ContactList { ); let user_id = user.id; + let github_login = &user.github_login; let is_contact_request_pending = user_store.read(cx).is_contact_request_pending(&user); let button_spacing = theme.contact_button_spacing; @@ -1264,7 +1276,10 @@ impl ContactList { .with_padding(Padding::uniform(2.)) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, cx| { - cx.dispatch_action(RemoveContact(user_id)) + cx.dispatch_action(RemoveContact { + user_id, + github_login, + }) }) .flex_float() .boxed(),