From 66a549e1331fb85a04d34294b1197e6848a76954 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 11 Sep 2013 03:45:20 -0400
Subject: [PATCH] After message is sent refresh messages list of replied message folder (#1489249)

---
 CHANGELOG                       |    1 +
 program/steps/mail/compose.inc  |    2 ++
 program/steps/mail/sendmail.inc |   21 +++++++++++++++------
 program/js/app.js               |   10 ++++++----
 4 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 35b08a7..7c15aaf 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- After message is sent refresh messages list of replied message folder (#1489249)
 - Add option force specified domain in user login - username_domain_forced (#1489264)
 - Fix issue where From address was removed from Cc and Bcc fields when editing a draft (#1489319)
 - Add option to import Vcards with group assignments
diff --git a/program/js/app.js b/program/js/app.js
index dedad37..166b082 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3783,7 +3783,7 @@
     this.env.search_id = null;
   };
 
-  this.sent_successfully = function(type, msg, target)
+  this.sent_successfully = function(type, msg, folders)
   {
     this.display_message(msg, type);
 
@@ -3792,9 +3792,11 @@
       this.lock_form(this.gui_objects.messageform);
       if (rc) {
         rc.display_message(msg, type);
-        // refresh the folder where sent message was saved
-        if (target && rc.env.task == 'mail' && rc.env.action == '' && rc.env.mailbox == target)
-          rc.command('checkmail');
+        // refresh the folder where sent message was saved or replied message comes from
+        if (folders && rc.env.task == 'mail' && rc.env.action == '' && $.inArray(rc.env.mailbox, folders) >= 0) {
+          // @TODO: try with 'checkmail' here when #1485186 is fixed. See also #1489249.
+          rc.command('list', rc.env.mailbox);
+        }
       }
       setTimeout(function(){ window.close() }, 1000);
     }
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 4a0e52b..e9f638c 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -165,6 +165,8 @@
 else if ($msg_uid = $COMPOSE['param']['uid']) {
   $compose_mode = RCUBE_COMPOSE_EDIT;
 }
+
+$COMPOSE['mode'] = $compose_mode;
 $OUTPUT->set_env('compose_mode', $compose_mode);
 
 $config_show_sig = $RCMAIL->config->get('show_sig', 1);
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 1a92844..779fb87 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -823,15 +823,24 @@
 
   // start the auto-save timer again
   $OUTPUT->command('auto_save_start');
-
-  $OUTPUT->send('iframe');
 }
 else {
+  $folders = array();
+
+  if ($COMPOSE['mode'] == 'reply' || $COMPOSE['mode'] == 'forward')
+    $folders[] = $COMPOSE['mailbox'];
+
   rcmail_compose_cleanup($COMPOSE_ID);
 
   if ($store_folder && !$saved)
-    $OUTPUT->command('sent_successfully', 'error', rcube_label('errorsavingsent'));
-  else
-    $OUTPUT->command('sent_successfully', 'confirmation', rcube_label('messagesent'), $store_target);
-  $OUTPUT->send('iframe');
+    $OUTPUT->command('sent_successfully', 'error', rcube_label('errorsavingsent'), $folders);
+  else {
+    if ($store_folder) {
+      $folders[] = $store_target;
+    }
+
+    $OUTPUT->command('sent_successfully', 'confirmation', rcube_label('messagesent'), $folders);
+  }
 }
+
+$OUTPUT->send('iframe');

--
Gitblit v1.9.1