Display oldest unread message as preview: Closes #5921

This commit is contained in:
Jim Nelson 2013-08-13 19:21:30 -07:00
parent 1b7e652211
commit a803810db8

View file

@ -245,7 +245,20 @@ public class ConversationListStore : Gtk.ListStore {
folder_emails = new Gee.HashSet<Geary.EmailIdentifier>();
account_emails = new Gee.HashSet<Geary.EmailIdentifier>();
foreach (Geary.Conversation conversation in sorted_conversations) {
Geary.Email? need_preview = conversation.get_latest_email();
// find oldest unread message for the preview
Geary.Email? need_preview = null;
foreach (Geary.Email email in conversation.get_emails(Geary.Conversation.Ordering.DATE_ASCENDING)) {
if (email.email_flags.is_unread()) {
need_preview = email;
break;
}
}
// if all are read, use newest message
if (need_preview == null)
need_preview = conversation.get_latest_email();
if (need_preview == null)
continue;
@ -455,6 +468,11 @@ public class ConversationListStore : Gtk.ListStore {
private void on_email_flags_changed(Geary.Conversation conversation) {
refresh_flags(conversation);
// refresh previews because the oldest unread message is displayed as the preview, and if
// that's changed, need to change the preview
// TODO: need support code to load preview for single conversation, not scan all
refresh_previews_async.begin(conversation_monitor);
}
private int sort_by_date(Gtk.TreeModel model, Gtk.TreeIter aiter, Gtk.TreeIter biter) {