From 723f9e89f5732c0a3f65699d3a713beed32aefe2 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 2 Dec 2014 03:55:29 -0300 Subject: [PATCH] reuse plugin --- js/controllers/settings.js | 15 ++++++++------- js/services/localstorageService.js | 9 +++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 js/services/localstorageService.js diff --git a/js/controllers/settings.js b/js/controllers/settings.js index b8cfe2f45..012605b0a 100644 --- a/js/controllers/settings.js +++ b/js/controllers/settings.js @@ -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(); + }); }; }); diff --git a/js/services/localstorageService.js b/js/services/localstorageService.js new file mode 100644 index 000000000..7642775ea --- /dev/null +++ b/js/services/localstorageService.js @@ -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; + });