From 444eb6041ef7b0b5f1daacd5d0f18b0177ec9a0b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:27:25 +0000 Subject: [PATCH] feature(dom) saveDataToCache: add Cache.get --- lib/client/dom.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index fbd2c919..836fc545 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1758,20 +1758,25 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.saveDataToCache = function(name, data, callback) { CloudCmd.getConfig(function(config) { - var allowed = config.localStorage; + var cacheName, + allowed = config.localStorage; if (!allowed) Util.exec(callback); else { - Cache.set(name + '-data', data); - DOM.loadCurrentHash(function(hash) { - var isContain = Util.isContainStr(hash, 'error'); - - if (!isContain) - Cache.set(name + '-hash', hash); - - Util.exec(callback, hash); - }); + cacheName = name + '-data'; + + if (!!Cache.get(cacheName)) { + Cache.set(cacheName, data); + DOM.loadCurrentHash(function(hash) { + var isContain = Util.isContainStr(hash, 'error'); + + if (!isContain) + Cache.set(name + '-hash', hash); + + Util.exec(callback, hash); + }); + } } }); };