use new fee level only for the current transaction created

This commit is contained in:
Gabriel Bazán 2017-05-19 10:59:36 -03:00
commit 6521bbdcb4
9 changed files with 147 additions and 96 deletions

View file

@ -1,8 +1,15 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $rootScope, $timeout, $ionicHistory, lodash, gettextCatalog, configService, feeService, ongoingProcess, popupService) {
angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, $ionicHistory, lodash, gettextCatalog, configService, feeService, ongoingProcess, popupService) {
$scope.save = function(newFee) {
if ($scope.customFeeLevel) {
$scope.currentFeeLevel = newFee;
updateCurrentValues();
return;
}
var opts = {
wallet: {
settings: {
@ -21,18 +28,13 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', fu
});
};
function hideTabs() {
$timeout(function() {
$rootScope.hideTabs = 'tabs-item-hide';
$rootScope.$apply();
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.init();
});
if ($ionicHistory.backView() && ($ionicHistory.backView().stateName == 'tabs.send.confirm')) hideTabs();
$scope.init = function() {
$scope.feeOpts = feeService.feeOpts;
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
$scope.currentFeeLevel = $scope.customFeeLevel ? $scope.customFeeLevel : feeService.getCurrentFeeLevel();
$scope.loadingFee = true;
feeService.getFeeLevels(function(err, levels) {
$scope.loadingFee = false;
@ -45,7 +47,7 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', fu
updateCurrentValues();
$scope.$apply();
});
});
};
var updateCurrentValues = function() {
if (lodash.isEmpty($scope.feeLevels) || lodash.isEmpty($scope.currentFeeLevel)) return;
@ -60,4 +62,8 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', fu
$scope.feePerSatByte = (feeLevelValue.feePerKB / 1000).toFixed();
$scope.avgConfirmationTime = feeLevelValue.nbBlocks * 10;
};
$scope.chooseNewFee = function() {
$scope.hideModal($scope.currentFeeLevel);
};
});