From 9ee8792713615381635a97a51a467dc688c5d269 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 2 Feb 2010 11:22:43 -0700 Subject: [PATCH] Add DimpCore.bufferToRange() --- imp/js/DimpBase.js | 11 ++--------- imp/js/DimpCore.js | 36 +++++++++++++++++++++--------------- imp/lib/Views/ListMessages.php | 4 ++-- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index c9923f292..1a8f5bd51 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -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), diff --git a/imp/js/DimpCore.js b/imp/js/DimpCore.js index d1d152240..60c933b68 100644 --- a/imp/js/DimpCore.js +++ b/imp/js/DimpCore.js @@ -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) { diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index 3e4b53108..a47b595f2 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -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 -- 2.11.0