Merge pull request #367 from Bitcoin-com/wallet/task/546
Fix - Init variable when enter in the screens (send flow)
This commit is contained in:
commit
21f89a2f62
4 changed files with 148 additions and 95 deletions
|
|
@ -9,30 +9,6 @@ angular
|
||||||
function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, sendFlowService, shapeshiftService, txFormatService, platformInfo, ongoingProcess, popupService, profileService, walletService, $window) {
|
function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, sendFlowService, shapeshiftService, txFormatService, platformInfo, ongoingProcess, popupService, profileService, walletService, $window) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
// Variables
|
|
||||||
vm.allowSend = false;
|
|
||||||
vm.altCurrencyList = [];
|
|
||||||
vm.alternativeAmount = '';
|
|
||||||
vm.alternativeUnit = '';
|
|
||||||
vm.amount = '0';
|
|
||||||
vm.availableFunds = '';
|
|
||||||
vm.canSendAllAvailableFunds = true;
|
|
||||||
vm.errorMessage = '';
|
|
||||||
// Use insufficient for logic, as when the amount is invalid, funds being
|
|
||||||
// either sufficent or insufficient doesn't make sense.
|
|
||||||
vm.fundsAreInsufficient = false;
|
|
||||||
vm.globalResult = '';
|
|
||||||
vm.isRequestingSpecificAmount = false;
|
|
||||||
vm.listComplete = false;
|
|
||||||
vm.lastUsedPopularList = [];
|
|
||||||
vm.maxAmount = 0;
|
|
||||||
vm.minAmount = 0;
|
|
||||||
vm.sendableFunds = '';
|
|
||||||
vm.showSendMaxButton = false;
|
|
||||||
vm.showSendLimitMaxButton = false;
|
|
||||||
vm.thirdParty = null;
|
|
||||||
vm.unit = '';
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
vm.changeUnit = changeUnit;
|
vm.changeUnit = changeUnit;
|
||||||
vm.close = close;
|
vm.close = close;
|
||||||
|
|
@ -47,7 +23,6 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
vm.save = save;
|
vm.save = save;
|
||||||
vm.sendMax = sendMax;
|
vm.sendMax = sendMax;
|
||||||
|
|
||||||
|
|
||||||
$scope.$on('$ionicView.beforeEnter', onBeforeEnter);
|
$scope.$on('$ionicView.beforeEnter', onBeforeEnter);
|
||||||
$scope.$on('$ionicView.leave', onLeave);
|
$scope.$on('$ionicView.leave', onLeave);
|
||||||
|
|
||||||
|
|
@ -79,8 +54,55 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
satoshis: null
|
satoshis: null
|
||||||
};
|
};
|
||||||
|
|
||||||
function onLeave() {
|
function initVariables() {
|
||||||
angular.element($window).off('keydown');
|
// Private variables
|
||||||
|
altCurrencyModal = null;
|
||||||
|
altUnitIndex = 0;
|
||||||
|
availableUnits = [];
|
||||||
|
canSendMax = true;
|
||||||
|
fiatCode;
|
||||||
|
isNW = platformInfo.isNW;
|
||||||
|
isAndroid = platformInfo.isAndroid;
|
||||||
|
isIos = platformInfo.isIOS;
|
||||||
|
lastUsedAltCurrencyList = [];
|
||||||
|
passthroughParams = {};
|
||||||
|
satToUnit;
|
||||||
|
transactionSendableAmount = {
|
||||||
|
crypto: '',
|
||||||
|
satoshis: null
|
||||||
|
};
|
||||||
|
unitDecimals;
|
||||||
|
unitIndex = 0;
|
||||||
|
unitToSatoshi;
|
||||||
|
useSendMax = false;
|
||||||
|
walletSpendableAmount = {
|
||||||
|
crypto: '',
|
||||||
|
satoshis: null
|
||||||
|
};
|
||||||
|
|
||||||
|
// Public variables
|
||||||
|
vm.allowSend = false;
|
||||||
|
vm.altCurrencyList = [];
|
||||||
|
vm.alternativeAmount = '';
|
||||||
|
vm.alternativeUnit = '';
|
||||||
|
vm.amount = '0';
|
||||||
|
vm.availableFunds = '';
|
||||||
|
vm.canSendAllAvailableFunds = true;
|
||||||
|
vm.errorMessage = '';
|
||||||
|
// Use insufficient for logic, as when the amount is invalid, funds being
|
||||||
|
// either sufficent or insufficient doesn't make sense.
|
||||||
|
vm.fundsAreInsufficient = false;
|
||||||
|
vm.globalResult = '';
|
||||||
|
vm.isRequestingSpecificAmount = false;
|
||||||
|
vm.listComplete = false;
|
||||||
|
vm.lastUsedPopularList = [];
|
||||||
|
vm.maxAmount = 0;
|
||||||
|
vm.minAmount = 0;
|
||||||
|
vm.sendableFunds = '';
|
||||||
|
vm.showSendMaxButton = false;
|
||||||
|
vm.showSendLimitMaxButton = false;
|
||||||
|
vm.thirdParty = null;
|
||||||
|
vm.unit = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBeforeEnter(event, data) {
|
function onBeforeEnter(event, data) {
|
||||||
|
|
@ -89,12 +111,15 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Init before entering on this screen
|
||||||
|
initVariables();
|
||||||
initCurrencies();
|
initCurrencies();
|
||||||
|
// Then start
|
||||||
|
|
||||||
passthroughParams = sendFlowService.state.getClone();
|
passthroughParams = sendFlowService.state.getClone();
|
||||||
console.log('amount onBeforeEnter after back sendflow ', passthroughParams);
|
console.log('amount onBeforeEnter after back sendflow ', passthroughParams);
|
||||||
|
|
||||||
|
|
||||||
// Init thirdParty, should be done for all the variable
|
// Init thirdParty, should be done for all the variable
|
||||||
vm.thirdParty = null;
|
vm.thirdParty = null;
|
||||||
|
|
||||||
|
|
@ -223,6 +248,10 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onLeave() {
|
||||||
|
angular.element($window).off('keydown');
|
||||||
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
sendFlowService.router.goBack();
|
sendFlowService.router.goBack();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,55 +9,6 @@ angular
|
||||||
function reviewController(addressbookService, externalLinkService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, clipboardService, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, ionicToast, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, sendFlowService, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) {
|
function reviewController(addressbookService, externalLinkService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, clipboardService, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, ionicToast, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, sendFlowService, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
vm.buttonText = '';
|
|
||||||
vm.destination = {
|
|
||||||
address: '',
|
|
||||||
balanceAmount: '',
|
|
||||||
balanceCurrency: '',
|
|
||||||
coin: '',
|
|
||||||
color: '',
|
|
||||||
currency: '',
|
|
||||||
currencyColor: '',
|
|
||||||
kind: '', // 'address', 'contact', 'wallet'
|
|
||||||
name: ''
|
|
||||||
};
|
|
||||||
vm.displayAddress = '';
|
|
||||||
vm.feeCrypto = '';
|
|
||||||
vm.feeFiat = '';
|
|
||||||
vm.fiatCurrency = '';
|
|
||||||
vm.feeIsHigh = false;
|
|
||||||
vm.feeLessThanACent = false;
|
|
||||||
vm.isCordova = platformInfo.isCordova;
|
|
||||||
vm.memo = '';
|
|
||||||
vm.notReadyMessage = '';
|
|
||||||
vm.origin = {
|
|
||||||
balanceAmount: '',
|
|
||||||
balanceCurrency: '',
|
|
||||||
currency: '',
|
|
||||||
currencyColor: '',
|
|
||||||
};
|
|
||||||
vm.originWallet = null;
|
|
||||||
vm.paymentExpired = false;
|
|
||||||
vm.personalNotePlaceholder = gettextCatalog.getString('Enter text here');
|
|
||||||
vm.primaryAmount = '';
|
|
||||||
vm.primaryCurrency = '';
|
|
||||||
vm.usingMerchantFee = false;
|
|
||||||
vm.readyToSend = false;
|
|
||||||
vm.remainingTimeStr = '';
|
|
||||||
vm.secondaryAmount = '';
|
|
||||||
vm.secondaryCurrency = '';
|
|
||||||
vm.sendingTitle = gettextCatalog.getString('You are sending');
|
|
||||||
vm.sendStatus = '';
|
|
||||||
vm.showAddress = true;
|
|
||||||
vm.thirdParty = null;
|
|
||||||
vm.wallet = null;
|
|
||||||
vm.memoExpanded = false;
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
vm.goBack = goBack;
|
|
||||||
vm.onSuccessConfirm = onSuccessConfirm;
|
|
||||||
vm.onShareTransaction = onShareTransaction;
|
|
||||||
|
|
||||||
var sendFlowData;
|
var sendFlowData;
|
||||||
var config = null;
|
var config = null;
|
||||||
var coin = '';
|
var coin = '';
|
||||||
|
|
@ -77,13 +28,84 @@ angular
|
||||||
|
|
||||||
var FEE_TOO_HIGH_LIMIT_PERCENTAGE = 15;
|
var FEE_TOO_HIGH_LIMIT_PERCENTAGE = 15;
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
vm.goBack = goBack;
|
||||||
|
vm.onSuccessConfirm = onSuccessConfirm;
|
||||||
|
vm.onShareTransaction = onShareTransaction;
|
||||||
|
|
||||||
|
function initVariables() {
|
||||||
|
// Private variables
|
||||||
|
sendFlowData;
|
||||||
|
config = null;
|
||||||
|
coin = '';
|
||||||
|
countDown = null;
|
||||||
|
defaults = {};
|
||||||
|
usingCustomFee = false;
|
||||||
|
usingMerchantFee = false;
|
||||||
|
destinationWalletId = '';
|
||||||
|
lastTxId = '';
|
||||||
|
originWalletId = '';
|
||||||
|
priceDisplayIsFiat = true;
|
||||||
|
satoshis = null;
|
||||||
|
toAddress = '';
|
||||||
|
tx = {};
|
||||||
|
txPayproData = null;
|
||||||
|
unitFromSat = 0;
|
||||||
|
|
||||||
|
// Public variables
|
||||||
|
vm.buttonText = '';
|
||||||
|
vm.destination = {
|
||||||
|
address: '',
|
||||||
|
balanceAmount: '',
|
||||||
|
balanceCurrency: '',
|
||||||
|
coin: '',
|
||||||
|
color: '',
|
||||||
|
currency: '',
|
||||||
|
currencyColor: '',
|
||||||
|
kind: '', // 'address', 'contact', 'wallet'
|
||||||
|
name: ''
|
||||||
|
};
|
||||||
|
vm.displayAddress = '';
|
||||||
|
vm.feeCrypto = '';
|
||||||
|
vm.feeFiat = '';
|
||||||
|
vm.fiatCurrency = '';
|
||||||
|
vm.feeIsHigh = false;
|
||||||
|
vm.feeLessThanACent = false;
|
||||||
|
vm.isCordova = platformInfo.isCordova;
|
||||||
|
vm.memo = '';
|
||||||
|
vm.notReadyMessage = '';
|
||||||
|
vm.origin = {
|
||||||
|
balanceAmount: '',
|
||||||
|
balanceCurrency: '',
|
||||||
|
currency: '',
|
||||||
|
currencyColor: '',
|
||||||
|
};
|
||||||
|
vm.originWallet = null;
|
||||||
|
vm.paymentExpired = false;
|
||||||
|
vm.personalNotePlaceholder = gettextCatalog.getString('Enter text here');
|
||||||
|
vm.primaryAmount = '';
|
||||||
|
vm.primaryCurrency = '';
|
||||||
|
vm.usingMerchantFee = false;
|
||||||
|
vm.readyToSend = false;
|
||||||
|
vm.remainingTimeStr = '';
|
||||||
|
vm.secondaryAmount = '';
|
||||||
|
vm.secondaryCurrency = '';
|
||||||
|
vm.sendingTitle = gettextCatalog.getString('You are sending');
|
||||||
|
vm.sendStatus = '';
|
||||||
|
vm.showAddress = true;
|
||||||
|
vm.thirdParty = null;
|
||||||
|
vm.wallet = null;
|
||||||
|
vm.memoExpanded = false;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
||||||
|
|
||||||
function onBeforeEnter(event, data) {
|
function onBeforeEnter(event, data) {
|
||||||
$log.debug('reviewController onBeforeEnter sendflow ', sendFlowService.state);
|
$log.debug('reviewController onBeforeEnter sendflow ', sendFlowService.state);
|
||||||
|
|
||||||
// Reset from last time
|
// Init before entering on this screen
|
||||||
vm.thirdParty = null;
|
initVariables();
|
||||||
|
// Then start
|
||||||
|
|
||||||
defaults = configService.getDefaults();
|
defaults = configService.getDefaults();
|
||||||
sendFlowData = sendFlowService.state.getClone();
|
sendFlowData = sendFlowService.state.getClone();
|
||||||
|
|
@ -727,20 +749,7 @@ angular
|
||||||
$timeout(function onTimeout() {
|
$timeout(function onTimeout() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// setWalletSelector(tx.coin, tx.network, tx.amount, function(err) {
|
|
||||||
// if (err) {
|
|
||||||
// return exitWithError('Could not update wallets');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (vm.wallets.length > 1) {
|
|
||||||
// vm.showWalletSelector();
|
|
||||||
// } else if (vm.wallets.length) {
|
|
||||||
// setWallet(vm.wallets[0], tx);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSendMaxWarning(wallet, sendMaxInfo) {
|
function showSendMaxWarning(wallet, sendMaxInfo) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,17 @@ angular
|
||||||
var unitDecimals = 0;
|
var unitDecimals = 0;
|
||||||
var unitsFromSatoshis = 0;
|
var unitsFromSatoshis = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Needs to migrate $scope to vm.
|
||||||
|
//
|
||||||
|
function initVariables() {
|
||||||
|
// Private variables
|
||||||
|
fromWalletId = '';
|
||||||
|
priceDisplayAsFiat = false;
|
||||||
|
unitDecimals = 0;
|
||||||
|
unitsFromSatoshis = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
||||||
$scope.$on("$ionicView.enter", onEnter);
|
$scope.$on("$ionicView.enter", onEnter);
|
||||||
|
|
||||||
|
|
@ -20,6 +31,10 @@ angular
|
||||||
sendFlowService.state.pop();
|
sendFlowService.state.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init before entering on this screen
|
||||||
|
initVariables();
|
||||||
|
// Then start
|
||||||
|
|
||||||
$scope.params = sendFlowService.state.getClone();
|
$scope.params = sendFlowService.state.getClone();
|
||||||
|
|
||||||
console.log('walletSelector onBeforeEnter after back sendflow', $scope.params);
|
console.log('walletSelector onBeforeEnter after back sendflow', $scope.params);
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ angular.module('copayApp.directives')
|
||||||
scope.type = "url";
|
scope.type = "url";
|
||||||
} else if (scope.data.parsed.publicAddress) {
|
} else if (scope.data.parsed.publicAddress) {
|
||||||
scope.type = "bitcoinAddress";
|
scope.type = "bitcoinAddress";
|
||||||
var prefix = scope.data.parsed.isTestnet ? 'bchtest:' : 'bitcoincash:';
|
var prefix = scope.data.coin === 'bch' ? (scope.data.parsed.isTestnet ? 'bchtest:' : 'bitcoincash:') : '';
|
||||||
scope.data.toAddress = (prefix + scope.data.parsed.publicAddress.cashAddr) || scope.data.parsed.publicAddress.legacy || scope.data.parsed.publicAddress.bitpay;
|
scope.data.toAddress = (scope.data.parsed.publicAddress.cashAddr ? prefix + scope.data.parsed.publicAddress.cashAddr : false) || scope.data.parsed.publicAddress.legacy || scope.data.parsed.publicAddress.bitpay;
|
||||||
} else {
|
} else {
|
||||||
scope.type = "text";
|
scope.type = "text";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue