X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fthread.cc;h=3738baa90978563dcfacc2b62f820402f8790fa1;hp=13872d46c781900865e8ca118a7027ff0665643e;hb=a4ce6cfbc63c53934c4c06f1b00ffef1c560b3b5;hpb=a258cb32b318d831fab5ef64329bd65119b47def diff --git a/lib/thread.cc b/lib/thread.cc index 13872d46..3738baa9 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -21,8 +21,6 @@ #include "notmuch-private.h" #include "database-private.h" -#include - #include #include /* GHashTable */ @@ -140,14 +138,14 @@ _complete_thread_authors (notmuch_thread_t *thread) thread->authors_array = NULL; } -/* clean up the uggly "Lastname, Firstname" format that some mail systems +/* clean up the ugly "Lastname, Firstname" format that some mail systems * (most notably, Exchange) are creating to be "Firstname Lastname" * To make sure that we don't change other potential situations where a * comma is in the name, we check that we match one of these patterns * "Last, First" * "Last, First MI" */ -char * +static char * _thread_cleanup_author (notmuch_thread_t *thread, const char *author, const char *from) { @@ -290,11 +288,17 @@ _thread_add_matched_message (notmuch_thread_t *thread, date = notmuch_message_get_date (message); - if (date < thread->oldest || ! thread->matched_messages) + if (date < thread->oldest || ! thread->matched_messages) { thread->oldest = date; + if (sort == NOTMUCH_SORT_OLDEST_FIRST) + _thread_set_subject_from_message (thread, message); + } - if (date > thread->newest || ! thread->matched_messages) + if (date > thread->newest || ! thread->matched_messages) { thread->newest = date; + if (sort != NOTMUCH_SORT_OLDEST_FIRST) + _thread_set_subject_from_message (thread, message); + } thread->matched_messages++; @@ -306,12 +310,6 @@ _thread_add_matched_message (notmuch_thread_t *thread, } _thread_add_matched_author (thread, notmuch_message_get_author (hashed_message)); - - if ((sort == NOTMUCH_SORT_OLDEST_FIRST && date <= thread->newest) || - (sort != NOTMUCH_SORT_OLDEST_FIRST && date == thread->newest)) - { - _thread_set_subject_from_message (thread, message); - } } static void