now plugins can be read on runtime
This commit is contained in:
parent
e4f5862576
commit
93b287bedc
5 changed files with 67 additions and 41 deletions
|
|
@ -4,20 +4,31 @@ angular.module('copayApp.services').factory('configService', function(localstora
|
|||
var root = {};
|
||||
|
||||
root.set = function(opts, cb) {
|
||||
copay.logger.setLevel(opts.logLevel);
|
||||
localstorageService.getItem('config', function(err, oldOps) {
|
||||
|
||||
_.defaults(opts, JSON.parse(oldOps));
|
||||
if (opts.logLevel)
|
||||
copay.logger.setLevel(opts.logLevel);
|
||||
|
||||
localstorageService.getItem('config', function(err, oldOpsStr) {
|
||||
|
||||
var oldOpts = {};
|
||||
|
||||
try {
|
||||
oldOpts = JSON.parse(oldOpsStr);
|
||||
} catch (e) {};
|
||||
|
||||
var newOpts = {};
|
||||
_.extend(newOpts, copay.defaultConfig, oldOpts, opts);
|
||||
|
||||
// TODO remove this gloval variable.
|
||||
config = opts;
|
||||
localstorageService.setItem('config', JSON.stringify(opts), cb);
|
||||
config = newOpts;
|
||||
|
||||
localstorageService.setItem('config', JSON.stringify(newOpts), cb);
|
||||
});
|
||||
};
|
||||
|
||||
root.reset = function(cb) {
|
||||
config = copay.defaultConfig;
|
||||
localstorageService.removeItem('config',cb);
|
||||
localstorageService.removeItem('config', cb);
|
||||
};
|
||||
|
||||
return root;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue