thread_id, NULL,
(void **) &thread))
{
- if (threads_seen > first) {
+ if (threads_seen >= first) {
thread = _notmuch_thread_create (query, query->notmuch,
thread_id);
g_ptr_array_add (threads->threads, thread);
threads_seen++;
}
- if (thread)
- _notmuch_thread_add_message (thread, message);
-
notmuch_message_destroy (message);
messages_seen++;
+
+ if (max_threads >= 0 && threads_seen >= first + max_threads)
+ break;
}
/* Stop if we're not seeing any more messages. */