From 2144f9c43237056da7cb2a3224719faa118d1795 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 04 Jun 2010 03:18:26 -0400
Subject: [PATCH] - Skip UNSEEN counting when list is empty
---
program/steps/mail/list.inc | 7 ++++++-
program/steps/mail/func.inc | 8 ++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 5e53a75..d1850d6 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -551,12 +551,16 @@
}
-function rcmail_send_unread_count($mbox_name, $force=false)
+function rcmail_send_unread_count($mbox_name, $force=false, $count=null)
{
global $RCMAIL;
$old_unseen = $_SESSION['unseen_count'][$mbox_name];
- $unseen = $RCMAIL->imap->messagecount($mbox_name, 'UNSEEN', $force);
+
+ if ($count === null)
+ $unseen = $RCMAIL->imap->messagecount($mbox_name, 'UNSEEN', $force);
+ else
+ $unseen = $count;
if ($unseen != $old_unseen || ($mbox_name == 'INBOX'))
$RCMAIL->output->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index 85e71a1..cf38551 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -70,8 +70,13 @@
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
$_SESSION['search'][$_REQUEST['_search']] = $IMAP->get_search_set();
+// empty result? we'll skip UNSEEN counting in rcmail_send_unread_count()
+if (empty($search_request) && empty($a_headers)) {
+ $unseen = 0;
+}
+
// update mailboxlist
-rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']));
+rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']), $unseen);
// update message count display
$pages = ceil($count/$IMAP->page_size);
--
Gitblit v1.9.1