Merge pull request #1917 from matiu/ref/localstorage
reuse LocalStorage plugin
This commit is contained in:
commit
b3b0d7903e
2 changed files with 17 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $route, $location, $anchorScroll, notification, applicationService) {
|
angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $route, $location, $anchorScroll, notification, applicationService, localstorageService) {
|
||||||
$scope.title = 'Settings';
|
$scope.title = 'Settings';
|
||||||
$scope.defaultLanguage = config.defaultLanguage || 'en';
|
$scope.defaultLanguage = config.defaultLanguage || 'en';
|
||||||
$scope.insightLivenet = config.network.livenet.url;
|
$scope.insightLivenet = config.network.livenet.url;
|
||||||
|
|
@ -80,7 +80,7 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
||||||
plugins[$scope.selectedStorage.pluginName] = true;
|
plugins[$scope.selectedStorage.pluginName] = true;
|
||||||
copay.logger.setLevel($scope.selectedLogLevel.name);
|
copay.logger.setLevel($scope.selectedLogLevel.name);
|
||||||
|
|
||||||
localStorage.setItem('config', JSON.stringify({
|
localstorageService.setItem('config', JSON.stringify({
|
||||||
network: insightSettings,
|
network: insightSettings,
|
||||||
version: copay.version,
|
version: copay.version,
|
||||||
defaultLanguage: $scope.selectedLanguage.isoCode,
|
defaultLanguage: $scope.selectedLanguage.isoCode,
|
||||||
|
|
@ -92,15 +92,16 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
||||||
rates: _.extend(config.rates, {
|
rates: _.extend(config.rates, {
|
||||||
url: insightSettings.livenet.url + '/api/rates'
|
url: insightSettings.livenet.url + '/api/rates'
|
||||||
}),
|
}),
|
||||||
}));
|
}), function() {
|
||||||
|
applicationService.restart();
|
||||||
applicationService.restart();
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.reset = function() {
|
$scope.reset = function() {
|
||||||
localStorage.removeItem('config');
|
localstorageService.removeItem('config', function() {
|
||||||
applicationService.reload();
|
applicationService.reload();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
9
js/services/localstorageService.js
Normal file
9
js/services/localstorageService.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('copayApp.services')
|
||||||
|
.factory('localstorageService', function($rootScope) {
|
||||||
|
var LS = require('../plugins/LocalStorage');
|
||||||
|
var ls = new LS();
|
||||||
|
return ls;
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue