add configService
This commit is contained in:
parent
526bc53a7b
commit
e4f5862576
7 changed files with 73 additions and 43 deletions
24
js/services/configService.js
Normal file
24
js/services/configService.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('configService', function(localstorageService) {
|
||||
var root = {};
|
||||
|
||||
root.set = function(opts, cb) {
|
||||
copay.logger.setLevel(opts.logLevel);
|
||||
localstorageService.getItem('config', function(err, oldOps) {
|
||||
|
||||
_.defaults(opts, JSON.parse(oldOps));
|
||||
|
||||
// TODO remove this gloval variable.
|
||||
config = opts;
|
||||
localstorageService.setItem('config', JSON.stringify(opts), cb);
|
||||
});
|
||||
};
|
||||
|
||||
root.reset = function(cb) {
|
||||
config = copay.defaultConfig;
|
||||
localstorageService.removeItem('config',cb);
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue