Merge pull request #6158 from sdobz/null-transaction

get updated buy order if it does not initally include a transaction
This commit is contained in:
Gustavo Maximiliano Cortez 2017-06-06 10:09:45 -03:00 committed by GitHub
commit a0e273059e
2 changed files with 36 additions and 7 deletions

View file

@ -166,14 +166,14 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
showError(err);
return;
}
var tx = b.data ? b.data.transaction : null;
if (!tx) {
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
showError('Transaction not found');
return;
}
$timeout(function() {
var processBuyTx = function (tx) {
if (!tx) {
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
showError('Transaction not found');
return;
}
coinbaseService.getTransaction(accessToken, accountId, tx.id, function(err, updatedTx) {
if (err) {
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
@ -196,6 +196,24 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
});
});
});
};
$timeout(function() {
var tx = b.data ? b.data.transaction : null;
if (tx) {
processBuyTx(tx);
}
else {
coinbaseService.getBuyOrder(accessToken, accountId, b.data.id, function (err, buyResp) {
if (err) {
ongoingProcess.set('buyingBitcoin', false, statusChangeHandler);
showError(err);
return;
}
var tx = buyResp.data ? buyResp.data.transaction : null;
processBuyTx(tx);
});
}
}, 8000);
});
});