Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Sundgren committed Mar 29, 2022
1 parent 30aebf6 commit 4f1c689
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/view/frontend/web/js/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ define([
localStorage.remove('checkout-data');
localStorage.remove('cart');

// Why do we need this? Can it be removed?
// self.setCheckoutData();
this.cartData = customerData.get('cart');

Expand All @@ -54,12 +55,10 @@ define([
});

$(document).on('ajax:updateCartItemQty', function() {
collectorIframe.suspend();
self.fetchShippingRates();
});

$(document).on('ajax:removeFromCart', function() {
collectorIframe.suspend();
self.fetchShippingRates();
});

Expand Down Expand Up @@ -87,9 +86,9 @@ define([
*/
console.log("customer updated");
// TODO - This should be possible to be nicer!
if(typeof this.FirstTimeHasTriggered === 'undefined')
if(typeof this.FirstCustomerUpdateHasBeenTriggered === 'undefined')
{
this.FirstTimeHasTriggered= true;
this.FirstCustomerUpdateHasBeenTriggered = true;
}else{
this.addressUpdated(event);
}
Expand Down Expand Up @@ -397,7 +396,7 @@ define([

/** @inheritdoc */
beforeSend: function () {
collectorIframe.suspend();
collectorIframe.suspend();
},

/** @inheritdoc */
Expand Down
14 changes: 6 additions & 8 deletions src/view/frontend/web/js/iframe.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
define([
], function () {
'use strict';

var currentState = '';

// Make sure we dont do any resumes before user done a action that sends a suspend
var suspendActionHaveBeenTriggered = false;

function suspend() {
if (currentState == '' || currentState== 'resumed') {
window.collector.checkout.api.suspend();
console.log("suspended");
currentState = 'suspended';
}
suspendActionHaveBeenTriggered = true;
};
function resume() {
if (currentState == '' || currentState== 'suspended') {
if (suspendActionHaveBeenTriggered === true) {
window.collector.checkout.api.resume();
console.log("resumed");
currentState = 'resumed';
}
}
};

return {
Expand Down

0 comments on commit 4f1c689

Please sign in to comment.