Merge pull request #1917 from matiu/ref/localstorage

reuse LocalStorage plugin
This commit is contained in:
Gustavo Maximiliano Cortez 2014-12-02 11:03:34 -03:00
commit b3b0d7903e
2 changed files with 17 additions and 7 deletions

View File

@ -1,6 +1,6 @@
'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.defaultLanguage = config.defaultLanguage || 'en';
$scope.insightLivenet = config.network.livenet.url;
@ -80,7 +80,7 @@ angular.module('copayApp.controllers').controller('SettingsController', function
plugins[$scope.selectedStorage.pluginName] = true;
copay.logger.setLevel($scope.selectedLogLevel.name);
localStorage.setItem('config', JSON.stringify({
localstorageService.setItem('config', JSON.stringify({
network: insightSettings,
version: copay.version,
defaultLanguage: $scope.selectedLanguage.isoCode,
@ -92,15 +92,16 @@ angular.module('copayApp.controllers').controller('SettingsController', function
rates: _.extend(config.rates, {
url: insightSettings.livenet.url + '/api/rates'
}),
}));
applicationService.restart();
}), function() {
applicationService.restart();
});
};
$scope.reset = function() {
localStorage.removeItem('config');
applicationService.reload();
localstorageService.removeItem('config', function() {
applicationService.reload();
});
};
});

View 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;
});