The localStorageService now returns errors when they happen.
This commit is contained in:
parent
4109d4743f
commit
3aa9bef803
1 changed files with 12 additions and 5 deletions
|
|
@ -20,8 +20,7 @@ angular.module('copayApp.services')
|
||||||
if (isChromeApp || isNW) {
|
if (isChromeApp || isNW) {
|
||||||
chrome.storage.local.get(k,
|
chrome.storage.local.get(k,
|
||||||
function(data) {
|
function(data) {
|
||||||
//TODO check for errors
|
return cb(chrome.runtime.lastError, data[k]);
|
||||||
return cb(null, data[k]);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return cb(null, ls.getItem(k));
|
return cb(null, ls.getItem(k));
|
||||||
|
|
@ -56,16 +55,24 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
obj[k] = v;
|
obj[k] = v;
|
||||||
|
|
||||||
chrome.storage.local.set(obj, cb);
|
chrome.storage.local.set(obj, function(){
|
||||||
|
cb(chrome.runtime.lastError);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
ls.setItem(k, v);
|
try {
|
||||||
|
ls.setItem(k, v);
|
||||||
|
} catch (e) {
|
||||||
|
return cb(e);
|
||||||
|
}
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
root.remove = function(k, cb) {
|
root.remove = function(k, cb) {
|
||||||
if (isChromeApp || isNW) {
|
if (isChromeApp || isNW) {
|
||||||
chrome.storage.local.remove(k, cb);
|
chrome.storage.local.remove(k, function(){
|
||||||
|
cb(chrome.runtime.lastError);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
ls.removeItem(k);
|
ls.removeItem(k);
|
||||||
return cb();
|
return cb();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue