Add DimpCore.bufferToRange()
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 2 Feb 2010 18:22:43 +0000 (11:22 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 2 Feb 2010 18:32:33 +0000 (11:32 -0700)
imp/js/DimpBase.js
imp/js/DimpCore.js
imp/lib/Views/ListMessages.php

index c9923f2..1a8f5bd 100644 (file)
@@ -491,20 +491,13 @@ var DimpBase = {
                 DimpCore.doActionComplete(o);
             },
             onCachedList: function(id) {
-                var tmp, vs;
                 if (!this.cacheids[id]) {
-                    vs = this.viewport.getSelection(id);
+                    var vs = this.viewport.getSelection(id);
                     if (!vs.size()) {
                         return '';
                     }
 
-                    if (vs.getBuffer().getMetaData('search')) {
-                        this.cacheids[id] = vs.get('uid').toJSON();
-                    } else {
-                        tmp = {};
-                        tmp[id] = vs.get('uid').clone();
-                        this.cacheids[id] = DimpCore.toRangeString(tmp);
-                    }
+                    this.cacheids[id] = DimpCore.toRangeString(DimpCore.selectionToRange(vs));
                 }
                 return this.cacheids[id];
             }.bind(this),
index d1d1522..60c933b 100644 (file)
@@ -108,24 +108,11 @@ var DimpCore = {
         params = $H(params);
         opts = opts || {};
 
-        var b,
-            ajaxopts = Object.extend(this.doActionOpts, opts.ajaxopts || {}),
-            tmp = {};
+        var ajaxopts = Object.extend(this.doActionOpts, opts.ajaxopts || {});
 
         if (opts.uids) {
             if (opts.uids.viewport_selection) {
-                b = opts.uids.getBuffer();
-                if (b.getMetaData('search')) {
-                    opts.uids.get('dataob').each(function(r) {
-                        if (!tmp[r.view]) {
-                            tmp[r.view] = [];
-                        }
-                        tmp[r.view].push(r.imapuid);
-                    });
-                } else {
-                    tmp[b.getView()] = opts.uids.get('uid');
-                }
-                opts.uids = tmp;
+                opts.uids = this.selectionToRange(opts.uids);
             }
             params.set('uid', this.toRangeString(opts.uids));
         }
@@ -136,6 +123,25 @@ var DimpCore = {
         new Ajax.Request(DIMP.conf.URI_AJAX + action, ajaxopts);
     },
 
+    selectionToRange: function(s)
+    {
+        var b = s.getBuffer(),
+            tmp = {};
+
+        if (b.getMetaData('search')) {
+            s.get('dataob').each(function(r) {
+                if (!tmp[r.view]) {
+                    tmp[r.view] = [];
+                }
+                tmp[r.view].push(r.imapuid);
+            });
+        } else {
+            tmp[b.getView()] = s.get('uid');
+        }
+
+        return tmp;
+    },
+
     // params - (Hash)
     addRequestParams: function(params)
     {
index 3e4b531..a47b595 100644 (file)
@@ -172,10 +172,10 @@ class IMP_Views_ListMessages
         /* Get the cached list. */
         $cached = $changed = array();
         if (!empty($args['cache'])) {
+            $cached = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($args['cache']);
             if ($is_search) {
-                $cached = array_flip(Horde_Serialize::unserialize($args['cache'], Horde_Serialize::JSON));
+                $cached = array_flip($cached);
             } else {
-                $cached = $GLOBALS['imp_imap']->ob()->utils->fromSequenceString($args['cache']);
                 $cached = array_flip(reset($cached));
 
                 /* Check for cached entries marked as changed via CONDSTORE