file api working. Migration script missing
This commit is contained in:
parent
a8f882472d
commit
1f6596a5ad
9 changed files with 180 additions and 50 deletions
|
|
@ -1,12 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services')
|
||||
.factory('localStorageService', function() {
|
||||
|
||||
var isChromeApp = typeof window !== "undefined" && window.chrome && chrome.runtime && chrome.runtime.id;
|
||||
.factory('localStorageService', function(isChromeApp, $timeout) {
|
||||
var root = {};
|
||||
|
||||
var ls = ((typeof localStorage !== "undefined") ? localStorage : null);
|
||||
var ls = ((typeof window.localStorage !== "undefined") ? window.localStorage : null);
|
||||
|
||||
if (isChromeApp && !ls) {
|
||||
ls = localStorage = chrome.storage.local;
|
||||
|
|
@ -14,9 +11,7 @@ angular.module('copayApp.services')
|
|||
}
|
||||
|
||||
if (!ls)
|
||||
throw new Error('localstorage not available, cannot run plugin');
|
||||
|
||||
root.init = function() {};
|
||||
throw new Error('localstorage not available');
|
||||
|
||||
root.get = function(k, cb) {
|
||||
if (isChromeApp) {
|
||||
|
|
@ -26,7 +21,13 @@ angular.module('copayApp.services')
|
|||
return cb(null, data[k]);
|
||||
});
|
||||
} else {
|
||||
console.log('[localStorage.js.24]',k); //TODO
|
||||
console.log('[localStorage.js.25:TODO:]'); //TODO
|
||||
console.log('[localStorage.js.26:TODO:]'); //TODO
|
||||
console.log('[localStorage.js.27:TODO:]'); //TODO
|
||||
$timeout(function() {
|
||||
return cb(null, ls.getItem(k));
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -67,26 +68,5 @@ angular.module('copayApp.services')
|
|||
|
||||
};
|
||||
|
||||
root.clear = function(cb) {
|
||||
// NOP
|
||||
return cb();
|
||||
};
|
||||
|
||||
root.list = function(cb) {
|
||||
if (isChromeApp) {
|
||||
chrome.storage.local.get(null, function(items) {
|
||||
return cb(null, lodash.keys(items));
|
||||
});
|
||||
} else {
|
||||
var ret = [];
|
||||
var l = ls.length;
|
||||
|
||||
for (var i = 0; i < l; i++)
|
||||
ret.push(ls.key(i));
|
||||
|
||||
return cb(null, ret);
|
||||
}
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue