Update drafts mailbox in base screen if drafts have been added/removed
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 26 Jun 2009 17:19:43 +0000 (11:19 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 26 Jun 2009 17:20:04 +0000 (11:20 -0600)
imp/js/src/compose-dimp.js
imp/templates/javascript_defs_dimp.php

index 0cc3a2e..529c9fb 100644 (file)
@@ -10,8 +10,8 @@
 var DimpCompose = {
     // Variables defaulting to empty/false:
     //   auto_save_interval, button_pressed, compose_cursor, dbtext,
-    //   editor_on, mp_padding, resizebcc, resizecc, resizeto, row_height,
-    //   sbtext, skip_spellcheck, spellcheck, uploading
+    //   drafts_mbox, editor_on, mp_padding, resizebcc, resizecc, resizeto,
+    //   row_height, sbtext, skip_spellcheck, spellcheck, uploading
     last_msg: '',
     textarea_ready: true,
 
@@ -19,10 +19,19 @@ var DimpCompose = {
     {
         if (window.confirm(DIMP.text_compose.cancel)) {
             DimpCore.doAction(DIMP.conf_compose.auto_save_interval_val ? 'DeleteDraft' : 'CancelCompose', { imp_compose: $F('composeCache') });
+            this.updateDraftsMailbox();
             return this.closeCompose();
         }
     },
 
+    updateDraftsMailbox: function()
+    {
+        if (DIMP.baseWindow &&
+            DIMP.baseWindow.DimpBase.folder == DIMP.conf_compose.drafts_mbox) {
+            DIMP.baseWindow.DimpBase.poll();
+        }
+    },
+
     closeCompose: function()
     {
         if (DIMP.conf_compose.qreply) {
@@ -216,19 +225,18 @@ var DimpCompose = {
         if (d.success || d.action == 'add_attachment') {
             switch (d.action) {
             case 'auto_save_draft':
-                this.button_pressed = false;
-                break;
-
             case 'save_draft':
                 this.button_pressed = false;
-                if (DIMP.baseWindow) {
-                    DIMP.baseWindow.DimpBase.poll();
-                    if (!DIMP.conf_compose.qreply) {
+
+                this.updateDraftsMailbox();
+
+                if (d.action == 'save_draft') {
+                    if (DIMP.baseWindow && !DIMP.conf_compose.qreply) {
                         DIMP.baseWindow.DimpCore.showNotifications(r.msgs);
                     }
-                }
-                if (DIMP.conf_compose.close_draft) {
-                    return this.closeCompose();
+                    if (DIMP.conf_compose.close_draft) {
+                        return this.closeCompose();
+                    }
                 }
                 break;
 
index 721ea05..8cbc561 100644 (file)
@@ -134,6 +134,7 @@ if ($compose_mode) {
         'cc' => intval($GLOBALS['prefs']->getValue('compose_cc')),
         'close_draft' => intval($GLOBALS['prefs']->getValue('close_draft')),
         'compose_cursor' => ($compose_cursor ? $compose_cursor : 'top'),
+        'drafts_mbox' => IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true),
         'rte_avail' => intval($GLOBALS['browser']->hasFeature('rte')),
         'spellcheck' => intval($GLOBALS['prefs']->getValue('compose_spellcheck')),
     ));