mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
refactor(dom) saveDataToCache
This commit is contained in:
parent
b7d4277f6d
commit
6a3dc106c6
1 changed files with 17 additions and 14 deletions
|
|
@ -1486,6 +1486,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
lName += lExt;
|
||||
}
|
||||
|
||||
DOM.saveDataToCache(lName, pData);
|
||||
|
||||
Util.exec(pCallBack, {
|
||||
data: pData,
|
||||
name: lName
|
||||
|
|
@ -1758,25 +1760,26 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
*/
|
||||
this.saveDataToCache = function(name, data, callback) {
|
||||
CloudCmd.getConfig(function(config) {
|
||||
var cacheName,
|
||||
allowed = config.localStorage;
|
||||
var hash,
|
||||
nameHash = name + '-hash',
|
||||
nameData = name + '-data',
|
||||
allowed = config.localStorage;
|
||||
|
||||
if (!allowed)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
cacheName = name + '-data';
|
||||
hash = Cache.get(name + '-hash');
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
DOM.loadCurrentHash(function(pHash) {
|
||||
var isContain = Util.isContainStr(hash, 'error');
|
||||
|
||||
if (!isContain && hash !== pHash) {
|
||||
Cache.set(nameHash, pHash);
|
||||
Cache.set(nameData, data);
|
||||
}
|
||||
|
||||
Util.exec(callback, hash);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue