mirror of https://github.com/BTCPrivate/copay.git
request PIN to disable it - add disabled options
This commit is contained in:
parent
01343d120d
commit
328ec337e1
|
@ -12,6 +12,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
method: 'pin',
|
||||
label: gettextCatalog.getString('Lock by PIN'),
|
||||
needsBackup: null,
|
||||
disabled: null,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -20,15 +21,11 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
method: 'fingerprint',
|
||||
label: gettextCatalog.getString('Lock by Fingerprint'),
|
||||
needsBackup: null,
|
||||
disabled: null,
|
||||
});
|
||||
}
|
||||
|
||||
var config = configService.getSync();
|
||||
var method = config.lock && config.lock.method;
|
||||
if (!method) $scope.currentOption = $scope.options[0];
|
||||
else $scope.currentOption = lodash.find($scope.options, {
|
||||
'method': method
|
||||
});
|
||||
checkAndSelectOption();
|
||||
processWallets();
|
||||
};
|
||||
|
||||
|
@ -36,6 +33,26 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
init();
|
||||
});
|
||||
|
||||
function checkAndSelectOption() {
|
||||
var config = configService.getSync();
|
||||
var method = config.lock && config.lock.method;
|
||||
|
||||
if (!method) {
|
||||
$scope.currentOption = $scope.options[0];
|
||||
$scope.options[1].disabled = false;
|
||||
$scope.options[2].disabled = false;
|
||||
} else {
|
||||
if (method == 'fingerprint') $scope.options[1].disabled = true;
|
||||
if (method == 'pin') $scope.options[2].disabled = true;
|
||||
$scope.currentOption = lodash.find($scope.options, {
|
||||
'method': method
|
||||
});
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
function processWallets() {
|
||||
var wallets = profileService.getWallets();
|
||||
var singleLivenetWallet = wallets.length == 1 && wallets[0].network == 'livenet' && wallets[0].needsBackup;
|
||||
|
@ -73,9 +90,14 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
var config = configService.getSync();
|
||||
var savedMethod = config.lock && config.lock.method;
|
||||
|
||||
if (!selectedMethod)
|
||||
saveConfig();
|
||||
else if (selectedMethod == 'fingerprint') {
|
||||
if (!selectedMethod) {
|
||||
if (!savedMethod) return;
|
||||
if (savedMethod == 'pin') $state.transitionTo('tabs.pin', {
|
||||
fromSettings: true,
|
||||
locking: false,
|
||||
});
|
||||
else saveConfig();
|
||||
} else if (selectedMethod == 'fingerprint') {
|
||||
if (savedMethod == 'pin') {
|
||||
askForDisablePin(function(disablePin) {
|
||||
if (disablePin) saveConfig('fingerprint');
|
||||
|
@ -116,6 +138,7 @@ angular.module('copayApp.controllers').controller('lockSetupController', functio
|
|||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
checkAndSelectOption();
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
</ion-nav-bar>
|
||||
|
||||
<ion-content>
|
||||
<ion-radio ng-repeat="opt in options" ng-value="opt" ng-model="currentOption" ng-click="select(opt.method)" ng-disabled="opt.needsBackup">
|
||||
<span ng-class="{'disabled': opt.needsBackup}">{{opt.label}}</span>
|
||||
<ion-radio ng-repeat="opt in options" ng-value="opt" ng-model="currentOption" ng-click="select(opt.method)" ng-disabled="opt.needsBackup || opt.disabled">
|
||||
<span ng-class="{'disabled': opt.needsBackup || opt.disabled}">{{opt.label}}</span>
|
||||
</ion-radio>
|
||||
|
||||
<div class="assertive" style="text-align: center; margin: 4rem" ng-if="errorMsg">
|
||||
|
|
Loading…
Reference in New Issue