mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-05 20:08:03 +02:00
Take certID from backend instead of query params; Better loading; Uninstall app before updating
This commit is contained in:
parent
91e0af9b46
commit
d07d02b2bc
4 changed files with 23 additions and 13 deletions
|
@ -52,6 +52,7 @@ Rectangle {
|
||||||
property string referrer;
|
property string referrer;
|
||||||
property bool isInstalled;
|
property bool isInstalled;
|
||||||
property bool isUpdating;
|
property bool isUpdating;
|
||||||
|
property string baseAppURL;
|
||||||
// Style
|
// Style
|
||||||
color: hifi.colors.white;
|
color: hifi.colors.white;
|
||||||
Connections {
|
Connections {
|
||||||
|
@ -106,9 +107,9 @@ Rectangle {
|
||||||
if (result.status !== 'success') {
|
if (result.status !== 'success') {
|
||||||
console.log("Failed to get balance", result.data.message);
|
console.log("Failed to get balance", result.data.message);
|
||||||
} else {
|
} else {
|
||||||
root.balanceReceived = true;
|
|
||||||
root.balanceAfterPurchase = result.data.balance - root.itemPrice;
|
root.balanceAfterPurchase = result.data.balance - root.itemPrice;
|
||||||
root.refreshBuyUI();
|
root.refreshBuyUI();
|
||||||
|
root.balanceReceived = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +117,6 @@ Rectangle {
|
||||||
if (result.status !== 'success') {
|
if (result.status !== 'success') {
|
||||||
console.log("Failed to get Already Owned status", result.data.message);
|
console.log("Failed to get Already Owned status", result.data.message);
|
||||||
} else {
|
} else {
|
||||||
root.ownershipStatusReceived = true;
|
|
||||||
if (result.data.marketplace_item_id === root.itemId) {
|
if (result.data.marketplace_item_id === root.itemId) {
|
||||||
root.alreadyOwned = result.data.already_owned;
|
root.alreadyOwned = result.data.already_owned;
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,6 +124,7 @@ Rectangle {
|
||||||
root.alreadyOwned = false;
|
root.alreadyOwned = false;
|
||||||
}
|
}
|
||||||
root.refreshBuyUI();
|
root.refreshBuyUI();
|
||||||
|
root.ownershipStatusReceived = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,13 +138,20 @@ Rectangle {
|
||||||
if (result.status !== 'success') {
|
if (result.status !== 'success') {
|
||||||
console.log("Failed to get Available Updates", result.data.message);
|
console.log("Failed to get Available Updates", result.data.message);
|
||||||
} else {
|
} else {
|
||||||
root.availableUpdatesReceived = true;
|
|
||||||
for (var i = 0; i < result.data.updates.length; i++) {
|
for (var i = 0; i < result.data.updates.length; i++) {
|
||||||
if (result.data.updates[i].item_id === root.itemId) {
|
// If the ItemID of the item we're looking at matches EITHER the ID of a "base" item
|
||||||
|
// OR the ID of an "upgrade" item, we're updating.
|
||||||
|
if (root.itemId === result.data.updates[i].item_id ||
|
||||||
|
root.itemId === result.data.updates[i].updated_item_id) {
|
||||||
root.isUpdating = true;
|
root.isUpdating = true;
|
||||||
|
root.certificateId = result.data.updates[i].certificate_id;
|
||||||
|
if (root.itemType === "app") {
|
||||||
|
root.baseAppURL = result.data.updates[i].base_download_url;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
root.availableUpdatesReceived = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,6 +595,11 @@ Rectangle {
|
||||||
(viewInMyPurchasesButton.visible ? "Buy It Again" : "Confirm Purchase") : "--") : "Get Item"));
|
(viewInMyPurchasesButton.visible ? "Buy It Again" : "Confirm Purchase") : "--") : "Get Item"));
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (root.isUpdating) {
|
if (root.isUpdating) {
|
||||||
|
// If we're updating an app, the existing app needs to be uninstalled.
|
||||||
|
// This call will fail/return `false` if the app isn't installed, but that's OK.
|
||||||
|
if (root.itemType === "app") {
|
||||||
|
Commerce.uninstallApp(root.baseAppURL);
|
||||||
|
}
|
||||||
Commerce.updateItem(root.certificateId);
|
Commerce.updateItem(root.certificateId);
|
||||||
} else if (root.isCertified) {
|
} else if (root.isCertified) {
|
||||||
if (!root.shouldBuyWithControlledFailure) {
|
if (!root.shouldBuyWithControlledFailure) {
|
||||||
|
@ -1047,7 +1060,6 @@ Rectangle {
|
||||||
root.itemHref = message.params.itemHref;
|
root.itemHref = message.params.itemHref;
|
||||||
root.referrer = message.params.referrer;
|
root.referrer = message.params.referrer;
|
||||||
root.itemAuthor = message.params.itemAuthor;
|
root.itemAuthor = message.params.itemAuthor;
|
||||||
root.certificateId = message.params.certificateId;
|
|
||||||
refreshBuyUI();
|
refreshBuyUI();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -681,7 +681,7 @@ Item {
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
|
||||||
onLinkActivated: {
|
onLinkActivated: {
|
||||||
sendToPurchases({method: 'updateItemClicked', itemId: root.itemId, itemEdition: root.itemEdition, upgradeUrl: root.upgradeUrl, certificateId: root.certificateId});
|
sendToPurchases({method: 'updateItemClicked', itemId: root.itemId, itemEdition: root.itemEdition, upgradeUrl: root.upgradeUrl});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateButtonClicked(id, name, author, href, referrer, certId) {
|
function updateButtonClicked(id, name, author, href, referrer) {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "UPDATE",
|
type: "UPDATE",
|
||||||
isUpdating: true,
|
isUpdating: true,
|
||||||
|
@ -264,8 +264,7 @@
|
||||||
itemPrice: 0,
|
itemPrice: 0,
|
||||||
itemHref: href,
|
itemHref: href,
|
||||||
referrer: referrer,
|
referrer: referrer,
|
||||||
itemAuthor: author,
|
itemAuthor: author
|
||||||
certificateId: certId
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,13 +435,12 @@
|
||||||
purchaseButton.on('click', function () {
|
purchaseButton.on('click', function () {
|
||||||
var urlParams = new URLSearchParams(window.location.search);
|
var urlParams = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
if (window.location.href.indexOf('certificateId=' != -1)) {
|
if (window.location.href.indexOf('edition=' != -1)) { // "Upgrading" case
|
||||||
updateButtonClicked(window.location.pathname.split("/")[3],
|
updateButtonClicked(window.location.pathname.split("/")[3],
|
||||||
$('#top-center').find('h1').text(),
|
$('#top-center').find('h1').text(),
|
||||||
$('#creator').find('.value').text(),
|
$('#creator').find('.value').text(),
|
||||||
href,
|
href,
|
||||||
"itemPage",
|
"itemPage");
|
||||||
urlParams.get('certificateId'));
|
|
||||||
} else if ('available' === availability) {
|
} else if ('available' === availability) {
|
||||||
buyButtonClicked(window.location.pathname.split("/")[3],
|
buyButtonClicked(window.location.pathname.split("/")[3],
|
||||||
$('#top-center').find('h1').text(),
|
$('#top-center').find('h1').text(),
|
||||||
|
|
|
@ -564,7 +564,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'updateItemClicked':
|
case 'updateItemClicked':
|
||||||
tablet.gotoWebScreen(message.upgradeUrl + "?edition=" + message.itemEdition + "&certificateId=" + message.certificateId.replace(/\+/g, "%2B"),
|
tablet.gotoWebScreen(message.upgradeUrl + "?edition=" + message.itemEdition,
|
||||||
MARKETPLACES_INJECT_SCRIPT_URL);
|
MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'passphrasePopup_cancelClicked':
|
case 'passphrasePopup_cancelClicked':
|
||||||
|
|
Loading…
Reference in a new issue