From 609d3923d7dc674263ddea990387dbf5488fabc6 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 18 Sep 2011 05:02:35 -0400
Subject: [PATCH] - Cache synchronization using QRESYNC/CONDSTORE - Fixed message ID updates in cache - Changed message flags handling + some fixes (e.g. fixed messages listing after delete)

---
 program/steps/mail/check_recent.inc |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc
index 0eab345..c7d607c 100644
--- a/program/steps/mail/check_recent.inc
+++ b/program/steps/mail/check_recent.inc
@@ -34,16 +34,24 @@
 
 // check recent/unseen counts
 foreach ($a_mailboxes as $mbox_name) {
+    $is_current = $mbox_name == $current;
+    if ($is_current) {
+        // Synchronize mailbox cache, handle flag changes
+        $IMAP->mailbox_sync($mbox_name);
+    }
+
+    // Get mailbox status
     $status = $IMAP->mailbox_status($mbox_name);
 
     if ($status & 1) {
         // trigger plugin hook
-        $RCMAIL->plugins->exec_hook('new_messages', array('mailbox' => $mbox_name));
+        $RCMAIL->plugins->exec_hook('new_messages',
+            array('mailbox' => $mbox_name, 'is_current' => $is_current));
     }
 
     rcmail_send_unread_count($mbox_name, true);
 
-    if ($status && $mbox_name == $current) {
+    if ($status && $is_current) {
         // refresh saved search set
         $search_request = get_input_value('_search', RCUBE_INPUT_GPC);
         if ($search_request && isset($_SESSION['search'])

--
Gitblit v1.9.1