Upgrade specific edition

This commit is contained in:
Zach Fox 2018-03-13 13:51:10 -07:00
parent f42255f46b
commit 7b6b08fd26
2 changed files with 13 additions and 4 deletions

View file

@ -35,6 +35,7 @@ Rectangle {
property string itemId;
property string itemHref;
property string itemAuthor;
property int itemEdition: -1;
property string certificateId;
property double balanceAfterPurchase;
property bool alreadyOwned: false;
@ -143,6 +144,9 @@ Rectangle {
// OR the ID of an "updated" item, we're updating.
if (root.itemId === result.data.updates[i].item_id ||
root.itemId === result.data.updates[i].updated_item_id) {
if (root.itemEdition !== -1 && root.itemEdition !== result.data.updates[i].edition_number) {
continue;
}
root.isUpdating = true;
// This CertID is the one corresponding to the base item CertID that the user already owns
root.certificateId = result.data.updates[i].certificate_id;
@ -1059,6 +1063,7 @@ Rectangle {
root.itemHref = message.params.itemHref;
root.referrer = message.params.referrer;
root.itemAuthor = message.params.itemAuthor;
root.itemEdition = message.params.itemEdition;
refreshBuyUI();
break;
default:

View file

@ -243,7 +243,7 @@
});
}
function buyButtonClicked(id, name, author, price, href, referrer) {
function buyButtonClicked(id, name, author, price, href, referrer, edition) {
EventBridge.emitWebEvent(JSON.stringify({
type: "CHECKOUT",
itemId: id,
@ -251,7 +251,8 @@
itemPrice: price ? parseInt(price, 10) : 0,
itemHref: href,
referrer: referrer,
itemAuthor: author
itemAuthor: author,
itemEdition: edition
}));
}
@ -319,7 +320,8 @@
$(this).closest('.grid-item').find('.creator').find('.value').text(),
$(this).closest('.grid-item').find('.item-cost').text(),
$(this).attr('data-href'),
"mainPage");
"mainPage",
-1);
});
}
@ -411,6 +413,7 @@
var cost = $('.item-cost').text();
var isUpdating = window.location.href.indexOf('edition=') > -1;
var urlParams = new URLSearchParams(window.location.search);
if (isUpdating) {
purchaseButton.html('UPDATE FOR FREE');
} else if (availability !== 'available') {
@ -427,7 +430,8 @@
$('#creator').find('.value').text(),
cost,
href,
"itemPage");
"itemPage",
urlParams.get('edition'));
}
});
maybeAddPurchasesButton();