Commit 67744bd8 authored by Niels De Graef's avatar Niels De Graef

LinkSuggestionGrid: try more fields for the extra info.

parent 7ee9f463
......@@ -56,17 +56,38 @@ public class Contacts.LinkSuggestionGrid : Grid {
_("Is this the same person as %s from %s?").printf (contact.display_name, contact.format_persona_stores ())
: _("Is this the same person as %s?").printf (contact.display_name);
var emails = contact.individual.email_addresses;
if (!emails.is_empty) {
// This is of course a best guess.
var email = Utils.get_first<EmailFieldDetails>(emails);
if (email.value != null) {
this.extra_info_label.show ();
this.extra_info_label.label = email.value;
}
var extra_info = find_extra_description (contact);
if (extra_info != null) {
this.extra_info_label.show ();
this.extra_info_label.label = extra_info;
}
this.reject_button.clicked.connect ( () => suggestion_rejected ());
this.accept_button.clicked.connect ( () => suggestion_accepted ());
}
private string? find_extra_description (Contact contact) {
// First try an email address
var emails = contact.individual.email_addresses;
if (!emails.is_empty)
return Utils.get_first<EmailFieldDetails> (emails).value;
// Maybe a website? Works well with e.g. social media profiles
var urls = contact.individual.urls;
if (!urls.is_empty)
return Utils.get_first<UrlFieldDetails> (urls).value;
// Try a phone number
var phones = contact.individual.phone_numbers;
if (!phones.is_empty)
return Utils.get_first<PhoneFieldDetails> (phones).value;
// A postal address maybe?
var addresses = contact.individual.postal_addresses;
if (!addresses.is_empty)
return Utils.get_first<PostalAddressFieldDetails> (addresses).value.to_string ();
// We're out of ideas now.
return null;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment