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