]> granicus.if.org Git - neomutt/commitdiff
notmuch: rework progress update math
authorAustin Ray <austin@austinray.io>
Tue, 30 Oct 2018 19:36:23 +0000 (15:36 -0400)
committerAustin Ray <austin@austinray.io>
Tue, 30 Oct 2018 20:09:04 +0000 (16:09 -0400)
After architectural changes, NeoMutt was not updating the progress when
opening `virtual-mailboxes`. The math was out of date.

This commit corrects the math involved and removes the unnecessary
counting logic. If counting is necessary, use `nm_nonctx_get_count(...)`
in a future commit.

notmuch/mutt_notmuch.c

index 91457b89aae602ca6b5ad394ab35534b0aff205b..a1818552efefddcbc2feaf1c53cf9b26d58d0f03 100644 (file)
@@ -825,27 +825,17 @@ static void progress_update(struct Mailbox *m, notmuch_query_t *q)
 
   if (!mdata->progress_ready && q)
   {
-    unsigned int count;
     static char msg[STRING];
     snprintf(msg, sizeof(msg), _("Reading messages..."));
 
-#if LIBNOTMUCH_CHECK_VERSION(5, 0, 0)
-    if (notmuch_query_count_messages(q, &count) != NOTMUCH_STATUS_SUCCESS)
-      count = 0; /* may not be defined on error */
-#elif LIBNOTMUCH_CHECK_VERSION(4, 3, 0)
-    if (notmuch_query_count_messages_st(q, &count) != NOTMUCH_STATUS_SUCCESS)
-      count = 0; /* may not be defined on error */
-#else
-    count = notmuch_query_count_messages(q);
-#endif
-    mutt_progress_init(&mdata->progress, msg, MUTT_PROGRESS_MSG, ReadInc, count);
+    // The total mail count is in oldmsgcount, so use that instead of recounting.
+    mutt_progress_init(&mdata->progress, msg, MUTT_PROGRESS_MSG, ReadInc, mdata->oldmsgcount);
     mdata->progress_ready = true;
   }
 
   if (mdata->progress_ready)
   {
-    mutt_progress_update(&mdata->progress,
-                         m->msg_count + mdata->ignmsgcount - mdata->oldmsgcount, -1);
+    mutt_progress_update(&mdata->progress, m->msg_count + mdata->ignmsgcount, -1);
   }
 }