Commit 31aa176e authored by Michael Gratton's avatar Michael Gratton 🤞 Committed by Michael Gratton

Clean up client email util source file

parent 76ee0759
......@@ -2631,7 +2631,7 @@ public class GearyController : Geary.BaseObject {
// string substitution is a list of recipients of the email.
string message = _(
"Successfully sent mail to %s."
).printf(EmailUtil.to_short_recipient_display(rfc822.to));
).printf(Util.Email.to_short_recipient_display(rfc822.to));
InAppNotification notification = new InAppNotification(message);
this.main_window.add_notification(notification);
Libnotify.play_sound("message-sent-email");
......
......@@ -83,7 +83,7 @@ public class ConversationListStore : Gtk.ListStore {
Geary.App.Conversation a, b;
model.get(aiter, Column.CONVERSATION_OBJECT, out a);
model.get(biter, Column.CONVERSATION_OBJECT, out b);
return compare_conversation_ascending(a, b);
return Util.Email.compare_conversation_ascending(a, b);
}
......@@ -225,8 +225,10 @@ public class ConversationListStore : Gtk.ListStore {
// sort the conversations so the previews are fetched from the newest to the oldest, matching
// the user experience
Gee.TreeSet<Geary.App.Conversation> sorted_conversations = new Gee.TreeSet<Geary.App.Conversation>(
compare_conversation_descending);
Gee.TreeSet<Geary.App.Conversation> sorted_conversations =
new Gee.TreeSet<Geary.App.Conversation>(
Util.Email.compare_conversation_descending
);
sorted_conversations.add_all(this.conversations.read_only_view);
foreach (Geary.App.Conversation conversation in sorted_conversations) {
// find oldest unread message for the preview
......
......@@ -111,7 +111,7 @@ public class FormattedConversationData : Geary.BaseObject {
// Load preview-related data.
update_date_string();
this.subject = EmailUtil.strip_subject_prefixes(preview);
this.subject = Util.Email.strip_subject_prefixes(preview);
this.body = Geary.String.reduce_whitespace(preview.get_preview_as_string());
this.preview = preview;
......
......@@ -105,10 +105,15 @@ public class Libnotify : Geary.BaseObject {
string body;
int count = monitor.get_new_message_count(folder);
if (count <= 1) {
body = EmailUtil.strip_subject_prefixes(email);
body = Util.Email.strip_subject_prefixes(email);
} else {
body = ngettext("%s\n(%d other new message for %s)", "%s\n(%d other new messages for %s)", count - 1).printf(
EmailUtil.strip_subject_prefixes(email), count - 1, folder.account.information.display_name);
body = ngettext(
"%s\n(%d other new message for %s)",
"%s\n(%d other new messages for %s)", count - 1).printf(
Util.Email.strip_subject_prefixes(email),
count - 1,
folder.account.information.display_name
);
}
Gdk.Pixbuf? avatar = yield this.avatars.load(
......
......@@ -4,31 +4,39 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
public int compare_conversation_ascending(Geary.App.Conversation a, Geary.App.Conversation b) {
Geary.Email? a_latest = a.get_latest_recv_email(Geary.App.Conversation.Location.IN_FOLDER_OUT_OF_FOLDER);
Geary.Email? b_latest = b.get_latest_recv_email(Geary.App.Conversation.Location.IN_FOLDER_OUT_OF_FOLDER);
namespace Util.Email {
if (a_latest == null)
return (b_latest == null) ? 0 : -1;
else if (b_latest == null)
return 1;
public int compare_conversation_ascending(Geary.App.Conversation a,
Geary.App.Conversation b) {
Geary.Email? a_latest = a.get_latest_recv_email(
Geary.App.Conversation.Location.IN_FOLDER_OUT_OF_FOLDER
);
Geary.Email? b_latest = b.get_latest_recv_email(
Geary.App.Conversation.Location.IN_FOLDER_OUT_OF_FOLDER
);
// use date-received so newly-arrived messages float to the top, even if they're send date
// was earlier (think of mailing lists that batch up forwarded mail)
return Geary.Email.compare_recv_date_ascending(a_latest, b_latest);
}
public int compare_conversation_descending(Geary.App.Conversation a, Geary.App.Conversation b) {
return compare_conversation_ascending(b, a);
}
if (a_latest == null) {
return (b_latest == null) ? 0 : -1;
} else if (b_latest == null) {
return 1;
}
namespace EmailUtil {
// use date-received so newly-arrived messages float to the
// top, even if they're send date was earlier (think of
// mailing lists that batch up forwarded mail)
return Geary.Email.compare_recv_date_ascending(a_latest, b_latest);
}
public string strip_subject_prefixes(Geary.Email email) {
string? cleaned = (email.subject != null) ? email.subject.strip_prefixes() : null;
public int compare_conversation_descending(Geary.App.Conversation a,
Geary.App.Conversation b) {
return compare_conversation_ascending(b, a);
}
return !Geary.String.is_empty(cleaned) ? cleaned : _("(no subject)");
}
/** 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 a shortened recipient list suitable for display.
......
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