mirror of https://github.com/BTCPrivate/copay.git
code refactor
This commit is contained in:
parent
7b802b7f9a
commit
3f27c3d231
|
@ -22,6 +22,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
var isCordova = platformInfo.isCordova;
|
var isCordova = platformInfo.isCordova;
|
||||||
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
||||||
|
|
||||||
|
//custom fee flag
|
||||||
|
var usingCustomFee = null;
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
@ -202,7 +205,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
txp.inputs = tx.sendMaxInfo.inputs;
|
txp.inputs = tx.sendMaxInfo.inputs;
|
||||||
txp.fee = tx.sendMaxInfo.fee;
|
txp.fee = tx.sendMaxInfo.fee;
|
||||||
} else {
|
} else {
|
||||||
if (tx.feeLevel == 'custom') {
|
if (usingCustomFee) {
|
||||||
txp.feePerKb = tx.feeRate;
|
txp.feePerKb = tx.feeRate;
|
||||||
} else txp.feeLevel = tx.feeLevel;
|
} else txp.feeLevel = tx.feeLevel;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +255,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
feeService.getFeeRate(tx.network, tx.feeLevel, function(err, feeRate) {
|
feeService.getFeeRate(tx.network, tx.feeLevel, function(err, feeRate) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
if (tx.feeLevel != 'custom') tx.feeRate = feeRate;
|
if (!usingCustomFee) tx.feeRate = feeRate;
|
||||||
tx.feeLevelName = feeService.feeOpts[tx.feeLevel];
|
tx.feeLevelName = feeService.feeOpts[tx.feeLevel];
|
||||||
|
|
||||||
if (!wallet)
|
if (!wallet)
|
||||||
|
@ -559,7 +562,11 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
scope.network = tx.network;
|
scope.network = tx.network;
|
||||||
scope.feeLevel = tx.feeLevel;
|
scope.feeLevel = tx.feeLevel;
|
||||||
scope.noSave = true;
|
scope.noSave = true;
|
||||||
if (tx.feeLevel == 'custom') scope.feePerSatByte = (tx.feeRate / 1000).toFixed();
|
|
||||||
|
if (usingCustomFee) {
|
||||||
|
scope.customFeePerKB = tx.feeRate;
|
||||||
|
scope.feePerSatByte = (tx.feeRate / 1000).toFixed();
|
||||||
|
}
|
||||||
|
|
||||||
$ionicModal.fromTemplateUrl('views/modals/chooseFeeLevel.html', {
|
$ionicModal.fromTemplateUrl('views/modals/chooseFeeLevel.html', {
|
||||||
scope: scope,
|
scope: scope,
|
||||||
|
@ -573,14 +580,16 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
scope.chooseFeeLevelModal.show();
|
scope.chooseFeeLevelModal.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.hideModal = function(newFeeLevel, customFeePerKBValue) {
|
scope.hideModal = function(newFeeLevel, customFeePerKB) {
|
||||||
scope.chooseFeeLevelModal.hide();
|
scope.chooseFeeLevelModal.hide();
|
||||||
$log.debug('New fee level choosen:' + newFeeLevel + ' was:' + tx.feeLevel);
|
$log.debug('New fee level choosen:' + newFeeLevel + ' was:' + tx.feeLevel);
|
||||||
|
|
||||||
if (tx.feeLevel == newFeeLevel && !customFeePerKBValue) return;
|
usingCustomFee = newFeeLevel == 'custom' ? true : false;
|
||||||
|
|
||||||
|
if (tx.feeLevel == newFeeLevel && !usingCustomFee) return;
|
||||||
|
|
||||||
tx.feeLevel = newFeeLevel;
|
tx.feeLevel = newFeeLevel;
|
||||||
if (customFeePerKBValue) tx.feeRate = parseInt(customFeePerKBValue);
|
if (usingCustomFee) tx.feeRate = parseInt(customFeePerKB);
|
||||||
|
|
||||||
updateTx(tx, wallet, {
|
updateTx(tx, wallet, {
|
||||||
clearCache: true,
|
clearCache: true,
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
<div>
|
<div>
|
||||||
<span translate>Average confirmation time</span>:
|
<span translate>Average confirmation time</span>:
|
||||||
<span class="fee-minutes" ng-if="avgConfirmationTime && currentFeeLevel != 'custom'">{{avgConfirmationTime | amDurationFormat: 'minute'}}</span>
|
<span class="fee-minutes" ng-if="avgConfirmationTime && currentFeeLevel != 'custom'">{{avgConfirmationTime | amDurationFormat: 'minute'}}</span>
|
||||||
<span class="fee-minutes" ng-if="currentFeeLevel == 'custom' && !invalidCustomFeeEntered" translate>Could not be estimated</span>
|
<span class="fee-minutes" ng-if="currentFeeLevel == 'custom' && !invalidCustomFeeEntered && !loadingFee" translate>Could not be estimated</span>
|
||||||
<span ng-if="loadingFee || invalidCustomFeeEntered">...</span>
|
<span ng-if="loadingFee || invalidCustomFeeEntered">...</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span translate>Current fee rate for this policy</span>:
|
<span translate>Current fee rate for this policy</span>:
|
||||||
<span class="fee-rate" ng-if="feePerSatByte && !invalidCustomFeeEntered">{{feePerSatByte}} satoshis/byte</span>
|
<span class="fee-rate" ng-if="feePerSatByte && !invalidCustomFeeEntered && !loadingFee">{{feePerSatByte}} satoshis/byte</span>
|
||||||
<span ng-if="loadingFee || invalidCustomFeeEntered">...</span>
|
<span ng-if="loadingFee || invalidCustomFeeEntered">...</span>
|
||||||
</div>
|
</div>
|
||||||
<span ng-if="network!='livenet'">[{{network}}]</span>
|
<span ng-if="network!='livenet'">[{{network}}]</span>
|
||||||
|
|
Loading…
Reference in New Issue