Don't pass isUpdating around

This commit is contained in:
Zach Fox 2018-03-07 11:34:48 -08:00
parent d07d02b2bc
commit 08b2be85d2
3 changed files with 6 additions and 29 deletions

View file

@ -1051,9 +1051,6 @@ Rectangle {
function fromScript(message) {
switch (message.method) {
case 'updateCheckoutQML':
if (message.params.isUpdating) {
root.isUpdating = message.params.isUpdating;
}
root.itemId = message.params.itemId;
root.itemName = message.params.itemName.trim();
root.itemPrice = message.params.itemPrice;

View file

@ -255,19 +255,6 @@
}));
}
function updateButtonClicked(id, name, author, href, referrer) {
EventBridge.emitWebEvent(JSON.stringify({
type: "UPDATE",
isUpdating: true,
itemId: id,
itemName: name,
itemPrice: 0,
itemHref: href,
referrer: referrer,
itemAuthor: author
}));
}
function injectBuyButtonOnMainPage() {
var cost;
@ -423,25 +410,18 @@
}
var cost = $('.item-cost').text();
if (availability !== 'available') {
purchaseButton.html('UNAVAILABLE (' + availability + ')');
} else if (window.location.href.indexOf('certificateId=' != -1)) {
var isUpdating = window.location.href.indexOf('edition=') > -1;
if (isUpdating) {
purchaseButton.html('UPDATE FOR FREE');
} else if (availability !== 'available') {
purchaseButton.html('UNAVAILABLE (' + availability + ')');
} else if (parseInt(cost) > 0 && $('#side-info').find('#buyItemButton').size() === 0) {
purchaseButton.html('PURCHASE <span class="hifi-glyph hifi-glyph-hfc" style="filter:invert(1);background-size:20px;' +
'width:20px;height:20px;position:relative;top:5px;"></span> ' + cost);
}
purchaseButton.on('click', function () {
var urlParams = new URLSearchParams(window.location.search);
if (window.location.href.indexOf('edition=' != -1)) { // "Upgrading" case
updateButtonClicked(window.location.pathname.split("/")[3],
$('#top-center').find('h1').text(),
$('#creator').find('.value').text(),
href,
"itemPage");
} else if ('available' === availability) {
if ('available' === availability || isUpdating) {
buyButtonClicked(window.location.pathname.split("/")[3],
$('#top-center').find('h1').text(),
$('#creator').find('.value').text(),

View file

@ -420,7 +420,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
isDownloadBeingCancelled = false;
} else {
var parsedJsonMessage = JSON.parse(message);
if (parsedJsonMessage.type === "CHECKOUT" || parsedJsonMessage.type === "UPDATE") {
if (parsedJsonMessage.type === "CHECKOUT") {
wireEventBridge(true);
tablet.pushOntoStack(MARKETPLACE_CHECKOUT_QML_PATH);
tablet.sendToQml({