The localStorageService now returns errors when they happen.

This commit is contained in:
Brendon Duncan 2018-06-04 14:37:54 +12:00
commit 3aa9bef803

View file

@ -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();