[geary/mjog/mail-merge-plugin: 8/12] Util.Email.strip_subject_prefixes: Convert param to EmailHeaderSet



commit b11239db9dfe62ce513c7a2c26ab832afa02ae40
Author: Michael Gratton <mike vee net>
Date:   Thu May 7 17:22:24 2020 +1000

    Util.Email.strip_subject_prefixes: Convert param to EmailHeaderSet
    
    Provides some more flexibility in how it can be called.

 src/client/util/util-email.vala | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/client/util/util-email.vala b/src/client/util/util-email.vala
index 7a23919d..a18a45cf 100644
--- a/src/client/util/util-email.vala
+++ b/src/client/util/util-email.vala
@@ -32,10 +32,23 @@ namespace Util.Email {
         return compare_conversation_ascending(b, a);
     }
 
-    /** Returns the stripped subject line, or a placeholder if none. */
-    public string strip_subject_prefixes(Geary.Email email) {
-        string? cleaned = (email.subject != null) ? email.subject.strip_prefixes() : null;
-        return !Geary.String.is_empty(cleaned) ? cleaned : _("(No subject)");
+    /**
+     * Returns the subject for an email stripped of prefixes.
+     *
+     * If the email has no subject, returns a localised placeholder.
+     */
+    public string strip_subject_prefixes(Geary.EmailHeaderSet email) {
+        string? cleaned = null;
+        if (email.subject != null) {
+            cleaned = email.subject.strip_prefixes();
+        }
+        return (
+            !Geary.String.is_empty_or_whitespace(cleaned)
+            ? cleaned
+            // Translators: Label used when an email has a missing or
+            // an empty subject
+            : _("(No subject)")
+        );
     }
 
     /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]