From f5afc2033feed8c932f5715005ea2c8370c1765a Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 28 Feb 2019 15:10:55 -0800 Subject: [PATCH 1/5] work through stocking vs update issues, and cleanup --- .../qml/hifi/commerce/checkout/Checkout.qml | 41 ++++++++----------- .../hifi/commerce/marketplace/Marketplace.qml | 3 +- .../commerce/marketplace/MarketplaceItem.qml | 19 ++++----- .../hifi/commerce/purchases/PurchasedItem.qml | 2 +- .../qml/hifi/commerce/wallet/Wallet.qml | 4 -- 5 files changed, 27 insertions(+), 42 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 9589c842e6..93ca366d37 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -41,8 +41,8 @@ Rectangle { property string itemAuthor; property int itemEdition: -1; property bool hasSomethingToTradeIn: alreadyOwned && (itemEdition > 0); // i.e., don't trade in your artist's proof - property bool isTradingIn: isUpdating && hasSomethingToTradeIn; - property bool isStocking: availability === 'not for sale' && creator === Account.username; + property bool isTradingIn: canUpdate && hasSomethingToTradeIn; + property bool isStocking: (availability === 'not for sale') && (creator === Account.username) && ; property string certificateId; property double balanceAfterPurchase; property bool alreadyOwned: false; // Including proofs @@ -59,7 +59,7 @@ Rectangle { property bool canRezCertifiedItems: Entities.canRezCertified() || Entities.canRezTmpCertified(); property string referrer; property bool isInstalled; - property bool isUpdating; + property bool canUpdate; property string availability: "available"; property string creator: ""; property string baseAppURL; @@ -144,6 +144,7 @@ Rectangle { } onAvailableUpdatesResult: { + // Answers the updatable original item cert data still owned by this user that are EITHER instances of this marketplace id, or update to this marketplace id. if (result.status !== 'success') { console.log("Failed to get Available Updates", result.data.message); } else { @@ -155,7 +156,7 @@ Rectangle { if (root.itemEdition !== -1 && root.itemEdition !== parseInt(result.data.updates[i].edition_number)) { continue; } - root.isUpdating = true; + root.canUpdate = true; root.baseItemName = result.data.updates[i].base_item_title; // This CertID is the one corresponding to the base item CertID that the user already owns root.certificateId = result.data.updates[i].certificate_id; @@ -166,7 +167,7 @@ Rectangle { } } - if (result.data.updates.length === 0 || root.isUpdating) { + if (result.data.updates.length === 0 || root.canUpdate) { root.availableUpdatesReceived = true; refreshBuyUI(); } else { @@ -266,13 +267,6 @@ Rectangle { } } } - MouseArea { - enabled: titleBarContainer.usernameDropdownVisible; - anchors.fill: parent; - onClicked: { - titleBarContainer.usernameDropdownVisible = false; - } - } // // TITLE BAR END // @@ -481,7 +475,7 @@ Rectangle { FiraSansSemiBold { id: itemPriceText; text: isTradingIn ? "FREE\nUPDATE" : - (isStocking ? "Free for creator" : + (isStocking ? "Free for creator" : ((root.itemPrice === -1) ? "--" : ((root.itemPrice > 0) ? root.itemPrice : "FREE"))); // Text size size: isTradingIn ? 20 : 26; @@ -580,7 +574,7 @@ Rectangle { // "View in Inventory" button HifiControlsUit.Button { id: viewInMyPurchasesButton; - visible: isCertified && dataReady && (isUpdating ? !hasSomethingToTradeIn : alreadyOwned); + visible: isCertified && dataReady && (isTradingIn ? hasSomethingToTradeIn : alreadyOwned); color: hifi.buttons.blue; colorScheme: hifi.colorSchemes.light; anchors.top: buyTextContainer.visible ? buyTextContainer.bottom : checkoutActionButtonsContainer.top; @@ -588,9 +582,9 @@ Rectangle { height: 50; anchors.left: parent.left; anchors.right: parent.right; - text: root.isUpdating ? "UPDATE TO THIS ITEM FOR FREE" : "VIEW THIS ITEM IN YOUR INVENTORY"; + text: (canUpdate && !isTradingIn) ? "UPDATE TO THIS ITEM FOR FREE" : "VIEW THIS ITEM IN YOUR INVENTORY"; onClicked: { - if (root.isUpdating) { + if (root.canUpdate) { sendToScript({method: 'checkout_goToPurchases', filterText: root.baseItemName}); } else { sendToScript({method: 'checkout_goToPurchases', filterText: root.itemName}); @@ -602,7 +596,11 @@ Rectangle { HifiControlsUit.Button { id: buyButton; visible: isTradingIn || !alreadyOwned || isStocking || !(root.itemType === "avatar" || root.itemType === "app"); - enabled: (root.balanceAfterPurchase >= 0 && dataReady) || (!root.isCertified) || root.isUpdating; + property bool checkBalance: dataReady && (root.availability === "available") + enabled: (checkBalance && (balanceAfterPurchase >= 0)) || !isCertified || isTradingIn || isStocking; + text: isTradingIn ? "Confirm Update" : + (enabled ? (viewInMyPurchasesButton.visible ? "Get It Again" : (dataReady ? "Get Item" : "--")) : + (checkBalance ? "Insufficient Funds" : availability)) color: viewInMyPurchasesButton.visible ? hifi.buttons.white : hifi.buttons.blue; colorScheme: hifi.colorSchemes.light; anchors.top: viewInMyPurchasesButton.visible ? viewInMyPurchasesButton.bottom : @@ -611,13 +609,6 @@ Rectangle { height: 50; anchors.left: parent.left; anchors.right: parent.right; - text: isTradingIn ? - "CONFIRM UPDATE" : - (((root.isCertified) ? - (dataReady ? - ((viewInMyPurchasesButton.visible && !root.isUpdating) ? "Get It Again" : "Confirm") : - "--") : - "Get Item")); onClicked: { if (isTradingIn) { // If we're updating an app, the existing app needs to be uninstalled. @@ -1209,7 +1200,7 @@ Rectangle { buyText.text = ""; // If the user IS on the checkout page for the updated version of an owned item... - if (root.isUpdating) { + if (root.canUpdate) { // If the user HAS already selected a specific edition to update... if (hasSomethingToTradeIn) { buyText.text = "By pressing \"Confirm Update\", you agree to trade in your old item for the updated item that replaces it."; diff --git a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml index ca6838efea..a8b769703d 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml @@ -112,7 +112,7 @@ Rectangle { marketplaceItem.image_url = result.data.thumbnail_url; marketplaceItem.name = result.data.title; marketplaceItem.likes = result.data.likes; - if(result.data.has_liked !== undefined) { + if (result.data.has_liked !== undefined) { marketplaceItem.liked = result.data.has_liked; } marketplaceItem.creator = result.data.creator; @@ -122,6 +122,7 @@ Rectangle { marketplaceItem.attributions = result.data.attributions; marketplaceItem.license = result.data.license; marketplaceItem.availability = result.data.availability; + marketplaceItem.updated_item_id = result.updated_item_id; marketplaceItem.created_at = result.data.created_at; marketplaceItemScrollView.contentHeight = marketplaceItemContent.height; itemsList.visible = false; diff --git a/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml b/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml index 97e5c10a6b..e909d27e2b 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml @@ -2,7 +2,7 @@ // MarketplaceListItem.qml // qml/hifi/commerce/marketplace // -// MarketplaceListItem +// MarketplaceItem // // Created by Roxanne Skelly on 2019-01-22 // Copyright 2019 High Fidelity, Inc. @@ -34,6 +34,7 @@ Rectangle { property var categories: [] property int price: 0 property string availability: "unknown" + property string updated_item_id: "" property var attributions: [] property string description: "" property string license: "" @@ -42,7 +43,6 @@ Rectangle { property bool isLoggedIn: false; property int edition: -1; property bool supports3DHTML: false; - onCategoriesChanged: { categoriesListModel.clear(); @@ -264,15 +264,12 @@ Rectangle { } height: 50 - property bool isNFS: availability === "not for sale" // Note: server will say "sold out" or "invalidated" before it says NFS - property bool isMine: creator === Account.username - property bool isUpgrade: root.edition >= 0 - property int costToMe: ((isMine && isNFS) || isUpgrade) ? 0 : price - property bool isAvailable: costToMe >= 0 - - text: isUpgrade ? "UPGRADE FOR FREE" : (isAvailable ? (costToMe || "FREE") : availability) - enabled: isAvailable - buttonGlyph: isAvailable ? (costToMe ? hifi.glyphs.hfc : "") : "" + property bool isUpdate: root.edition >= 0 // Special case of updating from a specific older item + property bool isStocking: (creator === Account.username) && (availability === "not for sale") && !updated_item_id // Note: server will say "sold out" or "invalidated" before it says NFS + property bool isFreeSpecial: isStocking || isUpdate + enabled: isFreeSpecial || (availability === 'available') + buttonGlyph: (enabled && !isUpdate && (price > 0)) ? hifi.glyphs.hfc : "" + text: isUpdate ? "UPDATE FOR FREE" : (isStocking ? "FREE STOCK" : (enabled ? (price || "FREE") : availability)) color: hifi.buttons.blue onClicked: root.buy(); diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index df6e216b32..2c2fed1d8f 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -380,7 +380,7 @@ Item { if (updateButton.visible && uninstallButton.visible) { item.itemButtonText = ""; item.glyphSize = 20; - } else { + } else if (item) { item.itemButtonText = "Send to Trash"; item.glyphSize = 30; } diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index f8e2c9115b..ea74549084 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -40,10 +40,6 @@ Rectangle { source: "images/wallet-bg.jpg"; } - Component.onDestruction: { - KeyboardScriptingInterface.raised = false; - } - Connections { target: Commerce; From 416cde4c1f4e3efbe80c8d83d77bb3c6e55c82b1 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 28 Feb 2019 17:31:35 -0800 Subject: [PATCH 2/5] fix uses of updated_item_id that got lost --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 4 +++- .../resources/qml/hifi/commerce/marketplace/Marketplace.qml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 93ca366d37..60114e3db9 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -42,7 +42,7 @@ Rectangle { property int itemEdition: -1; property bool hasSomethingToTradeIn: alreadyOwned && (itemEdition > 0); // i.e., don't trade in your artist's proof property bool isTradingIn: canUpdate && hasSomethingToTradeIn; - property bool isStocking: (availability === 'not for sale') && (creator === Account.username) && ; + property bool isStocking: (availability === 'not for sale') && (creator === Account.username) && !updated_item_id; property string certificateId; property double balanceAfterPurchase; property bool alreadyOwned: false; // Including proofs @@ -61,6 +61,7 @@ Rectangle { property bool isInstalled; property bool canUpdate; property string availability: "available"; + property string updated_item_id: ""; property string creator: ""; property string baseAppURL; property int currentUpdatesPage: 1; @@ -1101,6 +1102,7 @@ Rectangle { root.itemAuthor = result.data.creator; root.itemType = result.data.item_type || "unknown"; root.availability = result.data.availability; + root.updated_item_id = result.data.updated_item_id || "" root.creator = result.data.creator; if (root.itemType === "unknown") { root.itemHref = result.data.review_url; diff --git a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml index a8b769703d..6e089843dc 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml @@ -122,7 +122,7 @@ Rectangle { marketplaceItem.attributions = result.data.attributions; marketplaceItem.license = result.data.license; marketplaceItem.availability = result.data.availability; - marketplaceItem.updated_item_id = result.updated_item_id; + marketplaceItem.updated_item_id = result.data.updated_item_id || ""; marketplaceItem.created_at = result.data.created_at; marketplaceItemScrollView.contentHeight = marketplaceItemContent.height; itemsList.visible = false; From 366dd935dda30aba1e44a168bdde7bf018cbeeac Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Fri, 1 Mar 2019 12:32:03 -0800 Subject: [PATCH 3/5] trading in has nothing to do with whether you own the new item --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 60114e3db9..c2bf745527 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -40,7 +40,7 @@ Rectangle { property string itemHref; property string itemAuthor; property int itemEdition: -1; - property bool hasSomethingToTradeIn: alreadyOwned && (itemEdition > 0); // i.e., don't trade in your artist's proof + property bool hasSomethingToTradeIn: itemEdition > 0; // i.e., don't trade in your artist's proof property bool isTradingIn: canUpdate && hasSomethingToTradeIn; property bool isStocking: (availability === 'not for sale') && (creator === Account.username) && !updated_item_id; property string certificateId; From ddfd437696e09de4bfab64bf15e0488c8c91b06a Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Tue, 5 Mar 2019 14:50:06 -0800 Subject: [PATCH 4/5] ensure error message when marketplace update fails --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index c2bf745527..3ace6f381f 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -180,7 +180,7 @@ Rectangle { onUpdateItemResult: { if (result.status !== 'success') { - failureErrorText.text = result.message; + failureErrorText.text = result.data ? (result.data.message || "Unknown Error") : JSON.stringify(result); root.activeView = "checkoutFailure"; } else { root.itemHref = result.data.download_url; From c6b2697b44532e1fd06789ca08c6484f6dfd2eb3 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 6 Mar 2019 13:28:55 -0800 Subject: [PATCH 5/5] cleanup --- .../resources/qml/hifi/commerce/marketplace/Marketplace.qml | 1 - .../qml/hifi/commerce/marketplace/MarketplaceItem.qml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml index 6e089843dc..3004af6c15 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml @@ -980,7 +980,6 @@ Rectangle { xhr.open("GET", url); xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { - console.log(xhr.responseText); licenseText.text = xhr.responseText; licenseInfo.visible = true; } diff --git a/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml b/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml index e909d27e2b..8c9d3c31c8 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml @@ -52,7 +52,7 @@ Rectangle { } onDescriptionChanged: { - + if(root.supports3DHTML) { descriptionTextModel.clear(); descriptionTextModel.append({text: description}); @@ -271,7 +271,7 @@ Rectangle { buttonGlyph: (enabled && !isUpdate && (price > 0)) ? hifi.glyphs.hfc : "" text: isUpdate ? "UPDATE FOR FREE" : (isStocking ? "FREE STOCK" : (enabled ? (price || "FREE") : availability)) color: hifi.buttons.blue - + onClicked: root.buy(); }