diff --git a/src/client/application/application-controller.vala b/src/client/application/application-controller.vala index c17066e5..5340cb0a 100644 --- a/src/client/application/application-controller.vala +++ b/src/client/application/application-controller.vala @@ -1640,7 +1640,7 @@ public class Application.Controller : Geary.BaseObject { // string substitution is a list of recipients of the email. string message = _( "Successfully sent mail to %s." - ).printf(Util.Email.to_short_recipient_display(sent.to)); + ).printf(Util.Email.to_short_recipient_display(sent)); Components.InAppNotification notification = new Components.InAppNotification(message); this.main_window.add_notification(notification); diff --git a/src/client/util/util-email.vala b/src/client/util/util-email.vala index bebd43bc..784cbdca 100644 --- a/src/client/util/util-email.vala +++ b/src/client/util/util-email.vala @@ -108,29 +108,48 @@ namespace Util.Email { * list contains more mailboxes then an indication of how many * additional are present. */ - public string to_short_recipient_display(Geary.RFC822.MailboxAddresses mailboxes) { - if (mailboxes.size == 0) { - // Translators: This is shown for displaying a list of - // email recipients that happens to be empty, - // i.e. contains no email addresses. - return _("(No recipients)"); + public string to_short_recipient_display(Geary.EmailHeaderSet headers) { + Geary.RFC822.MailboxAddresses? mailboxes = null; + int total = 0; + if (headers.to != null) { + mailboxes = headers.to; + total += headers.to.size; + } + if (headers.cc != null) { + if (mailboxes == null) { + mailboxes = headers.cc; + } + total += headers.cc.size; + } + if (headers.bcc != null) { + if (mailboxes == null) { + mailboxes = headers.bcc; + } + total += headers.bcc.size; } - // Always mention the first recipient - string first_recipient = mailboxes.get(0).to_short_display(); - if (mailboxes.size == 1) - return first_recipient; + /// Translators: This is shown for displaying a list of email + /// recipients that happens to be empty, i.e. contains no + /// email addresses. + string display = _("(No recipients)"); + if (total > 0) { + // Always mention the first recipient + display = mailboxes.get(0).to_short_display(); - // Translators: This is used for displaying a short list of - // email recipients lists with two or more addresses. The - // first (string) substitution is address of the first, the - // second substitution is the number of n - 1 remaining - // recipients. - return GLib.ngettext( - "%s and %d other", - "%s and %d others", - mailboxes.size - 1 - ).printf(first_recipient, mailboxes.size - 1); + if (total > 1) { + /// Translators: This is used for displaying a short + /// list of email recipients lists with two or more + /// addresses. The first (string) substitution is + /// address of the first, the second substitution is + /// the number of n - 1 remaining recipients. + display = GLib.ngettext( + "%s and %d other", + "%s and %d others", + total - 1 + ).printf(display, total - 1); + } + } + return display; } /**