Cache preview messages loaded in the background
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 30 Oct 2009 22:27:39 +0000 (16:27 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 30 Oct 2009 22:27:39 +0000 (16:27 -0600)
imp/js/DimpBase.js

index 6320499..0e04539 100644 (file)
@@ -1063,11 +1063,14 @@ var DimpBase = {
 
     _loadPreviewCallback: function(resp)
     {
-        var ppuid, row, search, tmp,
+        var bg, ppuid, row, search, tmp,
             pm = $('previewMsg'),
             r = resp.response,
             t = $('msgHeadersContent').down('THEAD');
 
+        bg = (this.pp &&
+              (this.pp.imapuid != r.uid || this.pp.view != r.mailbox));
+
         if (!r.error) {
             search = this.viewport.getSelection().search({ imapuid: { equal: [ r.uid ] }, view: { equal: [ r.mailbox ] } });
             if (search.size()) {
@@ -1076,17 +1079,13 @@ var DimpBase = {
             }
         }
 
-        if (this.pp &&
-            (this.pp.imapuid != r.uid ||
-             this.pp.view != r.mailbox)) {
-            return;
-        }
-
         if (r.error || this.viewport.getSelected().size() != 1) {
-            if (r.error) {
-                DimpCore.showNotifications([ { type: r.errortype, message: r.error } ]);
+            if (!bg) {
+                if (r.error) {
+                    DimpCore.showNotifications([ { type: r.errortype, message: r.error } ]);
+                }
+                this.clearPreviewPane();
             }
-            this.clearPreviewPane();
             return;
         }
 
@@ -1096,6 +1095,10 @@ var DimpBase = {
         this.ppcache[ppuid] = resp;
         this.ppfifo.push(ppuid);
 
+        if (bg) {
+            return;
+        }
+
         DimpCore.removeAddressLinks(pm);
 
         // Add subject