]> git.notmuchmail.org Git - notmuch/blobdiff - lib/thread.cc
thread: Fix sort of search when constructing threads.
[notmuch] / lib / thread.cc
index 9b37143d33a4b14aabd62ed20c13183d506ba714..1b6feab21626430a0f2247314372fba70612a653 100644 (file)
@@ -299,7 +299,7 @@ _notmuch_thread_create (void *ctx,
     thread->oldest = 0;
     thread->newest = 0;
 
     thread->oldest = 0;
     thread->newest = 0;
 
-    notmuch_query_set_sort (thread_id_query, NOTMUCH_SORT_OLDEST_FIRST);
+    notmuch_query_set_sort (thread_id_query, sort);
 
     for (messages = notmuch_query_search_messages (thread_id_query);
         notmuch_messages_valid (messages);
 
     for (messages = notmuch_query_search_messages (thread_id_query);
         notmuch_messages_valid (messages);
@@ -332,6 +332,8 @@ _notmuch_thread_create (void *ctx,
        if (unlikely (matched_query == NULL))
            return NULL;
 
        if (unlikely (matched_query == NULL))
            return NULL;
 
+       notmuch_query_set_sort (matched_query, sort);
+
        for (messages = notmuch_query_search_messages (matched_query);
             notmuch_messages_valid (messages);
             notmuch_messages_move_to_next (messages))
        for (messages = notmuch_query_search_messages (matched_query);
             notmuch_messages_valid (messages);
             notmuch_messages_move_to_next (messages))