Handle notifications in compose screen without msgs_auto awkwardness
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 21 Oct 2009 08:29:50 +0000 (02:29 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 21 Oct 2009 09:01:28 +0000 (03:01 -0600)
imp/compose-dimp.php
imp/js/compose-dimp.js
kronolith/js/kronolith.js

index 3a8d308..2f072cc 100644 (file)
@@ -72,7 +72,7 @@ if (count($_POST)) {
             $result->info = end($info);
             $result->imp_compose = $imp_compose->getCacheId();
         }
-        Horde::sendHTTPResponse(Horde::prepareResponse($result, $GLOBALS['imp_notify'], false), 'js-json');
+        Horde::sendHTTPResponse(Horde::prepareResponse($result, $GLOBALS['imp_notify']), 'js-json');
         exit;
     }
 
@@ -196,7 +196,7 @@ if (count($_POST)) {
         }
     }
 
-    Horde::sendHTTPResponse(Horde::prepareResponse($result, !$result->success || !Horde_Util::getFormData('nonotify')  ? $GLOBALS['imp_notify'] : null, false), 'json');
+    Horde::sendHTTPResponse(Horde::prepareResponse($result, $GLOBALS['imp_notify']), 'json');
     exit;
 }
 
index 099fe94..9e6c2a7 100644 (file)
@@ -10,8 +10,9 @@
 var DimpCompose = {
     // Variables defaulting to empty/false:
     //   auto_save_interval, button_pressed, compose_cursor, dbtext,
-    //   drafts_mbox, editor_on, knl, mp_padding, resizebcc, resizecc,
-    //   resizeto, row_height, sbtext, skip_spellcheck, spellcheck, uploading
+    //   drafts_mbox, editor_on, is_popup, knl, mp_padding, resizebcc,
+    //   resizecc, resizeto, row_height, sbtext, skip_spellcheck, spellcheck,
+    //   uploading
     last_msg: '',
     textarea_ready: true,
 
@@ -26,8 +27,7 @@ var DimpCompose = {
 
     updateDraftsMailbox: function()
     {
-        if (DIMP.baseWindow &&
-            DIMP.baseWindow.DimpBase &&
+        if (this.is_popup &&
             DIMP.baseWindow.DimpBase.folder == DIMP.conf_compose.drafts_mbox) {
             DIMP.baseWindow.DimpBase.poll();
         }
@@ -37,8 +37,7 @@ var DimpCompose = {
     {
         if (DIMP.conf_compose.qreply) {
             this.closeQReply();
-        } else if ((DIMP.baseWindow && DIMP.baseWindow.DimpBase) ||
-                   DIMP.conf_compose.popup) {
+        } else if (this.is_popup || DIMP.conf_compose.popup) {
             DimpCore.closePopup();
         } else {
             DimpCore.redirect(DIMP.conf.URI_DIMP);
@@ -150,7 +149,7 @@ var DimpCompose = {
 
     uniqueSubmit: function(action)
     {
-        var db, params, sb,
+        var db, sb,
             c = $('compose');
 
         if (DIMP.SpellCheckerObject &&
@@ -221,11 +220,7 @@ var DimpCompose = {
 
             // Use an AJAX submit here so that we can do javascript-y stuff
             // before having to close the window on success.
-            params = c.serialize(true);
-            if (!DIMP.baseWindow || !DIMP.baseWindow.DimpBase) {
-                params.nonotify = true;
-            }
-            DimpCore.doAction('*' + DIMP.conf.URI_COMPOSE, params, null, this.uniqueSubmitCallback.bind(this));
+            DimpCore.doAction('*' + DIMP.conf.URI_COMPOSE, c.serialize(true), null, this.uniqueSubmitCallback.bind(this));
         }
     },
 
@@ -251,10 +246,9 @@ var DimpCompose = {
                 this.updateDraftsMailbox();
 
                 if (d.action == 'save_draft') {
-                    if (DIMP.baseWindow &&
-                        DIMP.baseWindow.DimpBase &&
-                        !DIMP.conf_compose.qreply) {
+                    if (this.is_popup && !DIMP.conf_compose.qreply) {
                         DIMP.baseWindow.DimpCore.showNotifications(r.msgs);
+                        r.msgs = [];
                     }
                     if (DIMP.conf_compose.close_draft) {
                         return this.closeCompose();
@@ -264,7 +258,7 @@ var DimpCompose = {
 
             case 'send_message':
                 this.button_pressed = false;
-                if (DIMP.baseWindow && DIMP.baseWindow.DimpBase) {
+                if (this.is_popup) {
                     if (d.reply_type) {
                         DIMP.baseWindow.DimpBase.flag(d.reply_type == 'reply' ? '\\answered' : '$forwarded', true, { index: d.index, mailbox: d.reply_folder, noserver: true });
                     }
@@ -284,6 +278,7 @@ var DimpCompose = {
 
                     if (!DIMP.conf_compose.qreply) {
                         DIMP.baseWindow.DimpCore.showNotifications(r.msgs);
+                        r.msgs = [];
                     }
                 }
                 return this.closeCompose();
@@ -322,10 +317,6 @@ var DimpCompose = {
             }
             this.dbtext = this.sbtext = null;
         }
-
-        if (!r.msgs_noauto) {
-            DimpCore.showNotifications(r.msgs);
-        }
     },
 
     onNoSpellError: function(action)
@@ -758,6 +749,8 @@ var DimpCompose = {
         DimpCore.growler_log = false;
         DimpCore.init();
 
+        this.is_popup = (DIMP.baseWindow && DIMP.baseWindow.DimpBase);
+
         /* Attach event handlers. */
         document.observe('change', this.changeHandler.bindAsEventListener(this));
         Event.observe(window, 'resize', this.resizeMsgArea.bind(this));
index 8096595..9e37a59 100644 (file)
@@ -92,9 +92,7 @@ KronolithCore = {
         }
         this.server_error = 0;
 
-        if (!r.msgs_noauto) {
-            this.showNotifications(r.msgs);
-        }
+        this.showNotifications(r.msgs);
 
         if (this.onDoActionComplete) {
             this.onDoActionComplete(r);