]> git.notmuchmail.org Git - notmuch/commitdiff
lib: Set thread subject at the same time as setting thread->{oldest,newest}
authorCarl Worth <cworth@cworth.org>
Wed, 8 Dec 2010 00:26:38 +0000 (16:26 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 8 Dec 2010 00:27:03 +0000 (16:27 -0800)
We really want to change the thread subject at the same time we set
the date, (if the sort order indicates this is necessary). The
previous code for setting the thread subject was sensitive on the
query sort when adding matching messages. An independent bug fix is
about to change that query sort order, so we remove the dependency on
it here.

lib/thread.cc

index 7f15586286d9441e1199c6f63c1867944b4b645b..3738baa90978563dcfacc2b62f820402f8790fa1 100644 (file)
@@ -288,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++;
 
@@ -304,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