From ef0addc29d52e27743b1df2c0aef5c50d4bb05ab Mon Sep 17 00:00:00 2001 From: JDonadio Date: Tue, 18 Apr 2017 10:18:55 -0300 Subject: [PATCH] fix config.lock options by default --- src/js/controllers/lock.js | 14 +++++++------- src/js/controllers/pin.js | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/js/controllers/lock.js b/src/js/controllers/lock.js index 13c9fccb7..6a53bff7b 100644 --- a/src/js/controllers/lock.js +++ b/src/js/controllers/lock.js @@ -4,18 +4,18 @@ angular.module('copayApp.controllers').controller('lockController', function($st function init() { var config = configService.getSync(); - $scope.locking = config.lock.method != 'pin'; + $scope.locking = config.lock && config.lock.method == 'pin' ? false : true; $scope.options = [ { - method: 'none', + method: '', label: gettextCatalog.getString('Disabled'), - value: config.lock.method == '', + selected: config.lock && config.lock.method == '' ? true : false, }, { method: 'pin', label: gettextCatalog.getString('Enable PIN'), - value: config.lock.method == 'pin', + selected: config.lock && config.lock.method == 'pin' ? true : false, needsBackup: null, }, ]; @@ -24,12 +24,12 @@ angular.module('copayApp.controllers').controller('lockController', function($st $scope.options.push({ method: 'fingerprint', label: gettextCatalog.getString('Enable Fingerprint'), - value: config.lock.method == 'fingerprint', + selected: config.lock && config.lock.method == 'fingerprint' ? true : false, needsBackup: null, }); } - $scope.currentOption = lodash.find($scope.options, 'value'); + $scope.currentOption = lodash.find($scope.options, 'selected') || $scope.options[0]; processWallets(); }; @@ -71,7 +71,7 @@ angular.module('copayApp.controllers').controller('lockController', function($st }; $scope.select = function(method) { - if (method == 'none') + if (method == '') saveConfig(); else if (method == 'fingerprint') { var config = configService.getSync(); diff --git a/src/js/controllers/pin.js b/src/js/controllers/pin.js index 94dd15d40..ef48c0198 100644 --- a/src/js/controllers/pin.js +++ b/src/js/controllers/pin.js @@ -15,6 +15,7 @@ angular.module('copayApp.controllers').controller('pinController', function($sta $scope.$on("$ionicView.enter", function(event) { configService.whenAvailable(function(config) { + if (!config.lock) return; $scope.bannedUntil = config.lock.bannedUntil || null; if ($scope.bannedUntil) { var now = Math.floor(Date.now() / 1000); @@ -156,12 +157,13 @@ angular.module('copayApp.controllers').controller('pinController', function($sta function saveSettings(method, value) { var config = configService.getSync(); + var attempts = config.lock && config.lock.attempts ? config.lock.attempts : 0; var opts = { lock: { method: method || '', value: value || '', bannedUntil: null, - attempts: config.lock.attempts + 1, + attempts: attempts + 1, } };