Add Viewport#createSelectionBuffer()
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Nov 2010 23:59:25 +0000 (16:59 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Nov 2010 23:59:25 +0000 (16:59 -0700)
Creates a Viewport_Selection object containing all elements currently in
the buffer.

Using this fixes generating the cached message list sent in viewport
requests.  Most notably, deleting messages in threaded mailboxes -
we were unnecessarily downloading all message data again even though it
was cached on the browser.  Instead, we just need to update the threaded
sort information on message deletion.

imp/js/dimpbase.js
imp/js/viewport.js

index 94af48e..b95f590 100644 (file)
@@ -515,7 +515,7 @@ var DimpBase = {
             },
             onCachedList: function(id) {
                 if (!this.cacheids[id]) {
-                    var vs = this.viewport.getSelection(id);
+                    var vs = this.viewport.createSelectionBuffer(id);
                     if (!vs.size()) {
                         return '';
                     }
@@ -526,7 +526,7 @@ var DimpBase = {
             }.bind(this),
             onContentOffset: function(offset) {
                 if (this.uid) {
-                    var row = this.viewport.createSelection('rownum', this.viewport.getAllRows()).search({ imapuid: { equal: [ this.uid ] }, view: { equal: [ this.folder ] } });
+                    var row = this.viewport.createSelectionBuffer().search({ imapuid: { equal: [ this.uid ] }, view: { equal: [ this.folder ] } });
                     if (row.size()) {
                         this.rownum = row.get('rownum').first();
                     }
@@ -2383,7 +2383,7 @@ var DimpBase = {
         if (r.response &&
             r.response.mbox == this.folder) {
             r.response.flags.each(function(f) {
-                this.updateFlag(this.viewport.createSelection('rownum', this.viewport.getAllRows()), f, r.response.set);
+                this.updateFlag(this.viewport.createSelectionBuffer(), f, r.response.set);
             }, this);
         }
     },
@@ -2806,7 +2806,7 @@ var DimpBase = {
             vs = opts.vs;
         } else if (opts.uid) {
             vs = opts.mailbox
-                ? this.viewport.createSelection('rownum', this.viewport.getAllRows()).search({ imapuid: { equal: [ opts.uid ] }, view: { equal: [ opts.mailbox ] } })
+                ? this.viewport.createSelectionBuffer().search({ imapuid: { equal: [ opts.uid ] }, view: { equal: [ opts.mailbox ] } })
                 : this.viewport.createSelection('dataob', opts.uid);
         } else {
             vs = this.viewport.getSelected();
index 1a3519d..ac9195c 100644 (file)
@@ -1268,6 +1268,13 @@ var ViewPort = Class.create({
             : new ViewPort_Selection(this._getBuffer(this.view));
     },
 
+    // Creates a selection object comprising all entries contained in the buffer.
+    createSelectionBuffer: function(view)
+    {
+        return this.createSelection('rownum', this.getAllRows(view), view);
+    },
+
+
     getSelection: function(view)
     {
         var buffer = this._getBuffer(view);