aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/thread.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-11-12 23:10:04 -0800
committerGravatar Carl Worth <cworth@cworth.org>2009-11-12 23:10:04 -0800
commited2643333c3e347318cdf78f888fc2eb4e89d2ad (patch)
tree637565e818afd986b035e361c7d60c5e59d3c617 /lib/thread.cc
parenta5e9c06eb6d6334da8505a527be22cdd935aacfb (diff)
notmuch search: Fix thread dates to come only from matched messages.
We were properly sorting the threads based only on matched messages, but we were displaying the date based on the total messages in the thread, which led to inconsistent and very confusing results.
Diffstat (limited to 'lib/thread.cc')
-rw-r--r--lib/thread.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/thread.cc b/lib/thread.cc
index ffecc9d0..f2618ace 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -111,15 +111,24 @@ _thread_add_message (notmuch_thread_t *thread,
g_hash_table_insert (thread->tags, xstrdup (tag), NULL);
}
+ thread->total_messages++;
+}
+
+static void
+_thread_add_matched_message (notmuch_thread_t *thread,
+ notmuch_message_t *message)
+{
+ time_t date;
+
date = notmuch_message_get_date (message);
- if (date < thread->oldest || ! thread->total_messages)
+ if (date < thread->oldest || ! thread->matched_messages)
thread->oldest = date;
- if (date > thread->newest || ! thread->total_messages)
+ if (date > thread->newest || ! thread->matched_messages)
thread->newest = date;
- thread->total_messages++;
+ thread->matched_messages++;
}
/* Create a new notmuch_thread_t object for the given thread ID,
@@ -201,7 +210,7 @@ _notmuch_thread_create (void *ctx,
notmuch_messages_has_more (messages);
notmuch_messages_advance (messages))
{
- thread->matched_messages++;
+ _thread_add_matched_message (thread, notmuch_messages_get (messages));
}
notmuch_query_destroy (matched_query);