Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit f3243fa

Browse files
committed
Merge pull request #1414 from OpenBazaar/fixPurchaseStuckOnAPIFail
Fix purchase stuck on api fail
2 parents e0d86b5 + fa35429 commit f3243fa

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

js/views/buyDetailsVw.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ module.exports = Backbone.View.extend({
9797
moderatorPriceString = this.model.get('userCurrencyCode') == 'BTC' ?
9898
moderatorPriceBTC.toFixed(8) + " BTC" : moderatorPriceBTC.toFixed(8) + " BTC (" + newDisplayModeratorPrice + ")";
9999

100-
this.$el.find('.js-buyWizardBTCPrice').html(newBTCDisplayPrice+"BTC");
101-
this.$el.find('.js-buyWizardBTCShippingPrice').html(newBTCShippingDisplayPrice+"BTC");
100+
this.$('.js-buyWizardBTCPrice').html(newBTCDisplayPrice+"BTC");
101+
this.$('.js-buyWizardBTCShippingPrice').html(newBTCShippingDisplayPrice+"BTC");
102102

103103
if(userCurrency != 'BTC'){
104-
this.$el.find('.js-buyWizardPrice').html("("+newDisplayPrice+")");
105-
this.$el.find('.js-buyWizardShippingPrice').html("("+newDisplayShippingPrice+")");
104+
this.$('.js-buyWizardPrice').html("("+newDisplayPrice+")");
105+
this.$('.js-buyWizardShippingPrice').html("("+newDisplayShippingPrice+")");
106106
}
107107
this.$('.js-buyWizardModeratorPrice').attr('data-tooltip', moderatorPriceString);
108108
newAttributes.quantity = quantity;
@@ -113,8 +113,8 @@ module.exports = Backbone.View.extend({
113113

114114
lockForm: function(){
115115
"use strict";
116-
this.$el.find('.js-buyWizardQuantity').prop('disabled', true);
117-
this.$el.find('#buyWizardQuantity .numberSpinnerUp, #buyWizardQuantity .numberSpinnerDown').addClass('hide');
116+
this.$('.js-buyWizardQuantity').prop('disabled', true);
117+
this.$('#buyWizardQuantity .numberSpinnerUp, #buyWizardQuantity .numberSpinnerDown').addClass('hide');
118118
},
119119

120120
goToPurchases: function(){

js/views/buyWizardVw.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = baseVw.extend({
3636
'click .js-closeBuyWizardModal': 'closeWizard',
3737
'click .js-buyWizardNewAddressBtn': 'createNewAddress',
3838
'click .js-buyWizardModeratorRadio': 'modSelected',
39-
'click .js-buyWizardModNext': 'accNext',
39+
'click .js-buyWizardModNext': 'modNext',
4040
'click .js-buyWizardModBack': 'modBack',
4141
'click .js-buyWizardReturnNext': 'returnNext',
4242
'click .js-buyWizardAddressBack': 'addressPrev',
@@ -265,6 +265,11 @@ module.exports = baseVw.extend({
265265
this.accGoToID("#BuyWizardPaymentType");
266266
},
267267

268+
modNext: function(){
269+
this.accNext();
270+
this.setTotalPrice(); //in case it isn't set yet
271+
},
272+
268273
modBack: function(){
269274
this.accGoToID('#BuyWizardBitcoinWallet');
270275
},
@@ -445,16 +450,16 @@ module.exports = baseVw.extend({
445450
formData = new FormData(),
446451
moderatorID = this.model.get('selectedModerator').guid || "",
447452
selectedAddress = this.model.get('selectedAddress'),
448-
bitCoinReturnAddr = this.$el.find('#buyWizardBitcoinAddressInput').val();
453+
bitCoinReturnAddr = this.$('#buyWizardBitcoinAddressInput').val();
449454

450-
if (!this.$el.find('#buyWizardQuantity')[0].checkValidity()){
455+
if (!this.$('#buyWizardQuantity')[0].checkValidity()){
451456
messageModal.show(window.polyglot.t('errorMessages.saveError'), window.polyglot.t('errorMessages.missingError'));
452457
return;
453458
}
454459

455-
this.$el.find('.js-buyWizardSendPurchase').addClass('hide');
456-
this.$el.find('.js-buyWizardPendingMsg').removeClass('hide');
457-
this.$el.find('.js-buyWizardPurchaseBack').addClass('disabled');
460+
this.$('.js-buyWizardSendPurchase').addClass('hide');
461+
this.$('.js-buyWizardPendingMsg').removeClass('hide');
462+
this.$('.js-buyWizardPurchaseBack').addClass('disabled');
458463

459464
formData.append("id", this.model.get('id'));
460465

@@ -472,7 +477,7 @@ module.exports = baseVw.extend({
472477
formData.append("moderator", moderatorID);
473478
}
474479

475-
this.$el.find('.js-buyWizardSpinner').removeClass('hide');
480+
this.$('.js-buyWizardSpinner').removeClass('hide');
476481

477482
formData.append("refund_address", bitCoinReturnAddr);
478483

@@ -494,7 +499,11 @@ module.exports = baseVw.extend({
494499
} else {
495500
messageModal.show(window.polyglot.t('errorMessages.contractError'), window.polyglot.t('errorMessages.sellerError') +" " +
496501
window.polyglot.t('errorMessages.checkPurchaseData') + "\n\n Reason: " + data.reason);
497-
self.$el.find('.js-buyWizardSpinner').addClass('hide');
502+
self.$('.js-buyWizardSpinner').addClass('hide');
503+
//re-enable form so they can try again
504+
self.$('.js-buyWizardSendPurchase').removeClass('hide');
505+
self.$('.js-buyWizardPendingMsg').addClass('hide');
506+
self.$('.js-buyWizardPurchaseBack').removeClass('disabled');
498507
}
499508
},
500509
error: function (jqXHR, status, errorThrown) {
@@ -562,8 +571,8 @@ module.exports = baseVw.extend({
562571
maximumFractionDigits: 2,
563572
currency: userCurrency
564573
}).format(totalPrice);
565-
this.$el.find('.js-buyWizardDetailsTotal').text(totalDisplayPrice);
566-
this.$el.find('.js-buyWizardDetailsBTCTotal').text(Number(totalBTCPrice.toFixed(8)));
574+
this.$('.js-buyWizardDetailsTotal').text(totalDisplayPrice);
575+
this.$('.js-buyWizardDetailsBTCTotal').text(Number(totalBTCPrice.toFixed(8)));
567576
},
568577

569578
copyPayAddress: function(){

0 commit comments

Comments
 (0)