fix config.lock options by default

This commit is contained in:
JDonadio 2017-04-18 10:18:55 -03:00
commit ef0addc29d
2 changed files with 10 additions and 8 deletions

View file

@ -4,18 +4,18 @@ angular.module('copayApp.controllers').controller('lockController', function($st
function init() { function init() {
var config = configService.getSync(); var config = configService.getSync();
$scope.locking = config.lock.method != 'pin'; $scope.locking = config.lock && config.lock.method == 'pin' ? false : true;
$scope.options = [ $scope.options = [
{ {
method: 'none', method: '',
label: gettextCatalog.getString('Disabled'), label: gettextCatalog.getString('Disabled'),
value: config.lock.method == '', selected: config.lock && config.lock.method == '' ? true : false,
}, },
{ {
method: 'pin', method: 'pin',
label: gettextCatalog.getString('Enable PIN'), label: gettextCatalog.getString('Enable PIN'),
value: config.lock.method == 'pin', selected: config.lock && config.lock.method == 'pin' ? true : false,
needsBackup: null, needsBackup: null,
}, },
]; ];
@ -24,12 +24,12 @@ angular.module('copayApp.controllers').controller('lockController', function($st
$scope.options.push({ $scope.options.push({
method: 'fingerprint', method: 'fingerprint',
label: gettextCatalog.getString('Enable Fingerprint'), label: gettextCatalog.getString('Enable Fingerprint'),
value: config.lock.method == 'fingerprint', selected: config.lock && config.lock.method == 'fingerprint' ? true : false,
needsBackup: null, needsBackup: null,
}); });
} }
$scope.currentOption = lodash.find($scope.options, 'value'); $scope.currentOption = lodash.find($scope.options, 'selected') || $scope.options[0];
processWallets(); processWallets();
}; };
@ -71,7 +71,7 @@ angular.module('copayApp.controllers').controller('lockController', function($st
}; };
$scope.select = function(method) { $scope.select = function(method) {
if (method == 'none') if (method == '')
saveConfig(); saveConfig();
else if (method == 'fingerprint') { else if (method == 'fingerprint') {
var config = configService.getSync(); var config = configService.getSync();

View file

@ -15,6 +15,7 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
$scope.$on("$ionicView.enter", function(event) { $scope.$on("$ionicView.enter", function(event) {
configService.whenAvailable(function(config) { configService.whenAvailable(function(config) {
if (!config.lock) return;
$scope.bannedUntil = config.lock.bannedUntil || null; $scope.bannedUntil = config.lock.bannedUntil || null;
if ($scope.bannedUntil) { if ($scope.bannedUntil) {
var now = Math.floor(Date.now() / 1000); var now = Math.floor(Date.now() / 1000);
@ -156,12 +157,13 @@ angular.module('copayApp.controllers').controller('pinController', function($sta
function saveSettings(method, value) { function saveSettings(method, value) {
var config = configService.getSync(); var config = configService.getSync();
var attempts = config.lock && config.lock.attempts ? config.lock.attempts : 0;
var opts = { var opts = {
lock: { lock: {
method: method || '', method: method || '',
value: value || '', value: value || '',
bannedUntil: null, bannedUntil: null,
attempts: config.lock.attempts + 1, attempts: attempts + 1,
} }
}; };