From eea4630d2bd4052b0c642e347b211aa1430f1003 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 24 Jul 2018 14:29:05 -0700 Subject: [PATCH] Fix MS16704: Remove worn Avatar/Wearable before updating --- .../hifi/commerce/purchases/PurchasedItem.qml | 3 +- .../qml/hifi/commerce/purchases/Purchases.qml | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index b2338d08de..032d9b0199 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -335,7 +335,8 @@ Item { upgradeUrl: root.upgradeUrl, itemHref: root.itemHref, itemType: root.itemType, - isInstalled: root.isInstalled + isInstalled: root.isInstalled, + wornEntityID: root.wornEntityID }); } } diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index 3569ce6767..3b8e2c0f4d 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -707,6 +707,12 @@ Rectangle { } } } else if (msg.method === "updateItemClicked") { + // These three cases are very similar to the conditionals below, under + // "if msg.method === "giftAsset". They differ in their popup's wording + // and the actions to take when continuing. + // I could see an argument for DRYing up this code, but I think the + // actions are different enough now and potentially moving forward such that I'm + // OK with "somewhat repeating myself". if (msg.itemType === "app" && msg.isInstalled) { lightboxPopup.titleText = "Uninstall App"; lightboxPopup.bodyText = "The app that you are trying to update is installed.

" + @@ -721,6 +727,35 @@ Rectangle { sendToScript(msg); }; lightboxPopup.visible = true; + } else if (msg.itemType === "wearable" && msg.wornEntityID !== '') { + lightboxPopup.titleText = "Remove Wearable"; + lightboxPopup.bodyText = "You are currently wearing the wearable that you are trying to update.

" + + "If you proceed, this wearable will be removed."; + lightboxPopup.button1text = "CANCEL"; + lightboxPopup.button1method = function() { + lightboxPopup.visible = false; + } + lightboxPopup.button2text = "CONFIRM"; + lightboxPopup.button2method = function() { + Entities.deleteEntity(msg.wornEntityID); + purchasesModel.setProperty(index, 'wornEntityID', ''); + sendToScript(msg); + }; + lightboxPopup.visible = true; + } else if (msg.itemType === "avatar" && MyAvatar.skeletonModelURL === msg.itemHref) { + lightboxPopup.titleText = "Change Avatar to Default"; + lightboxPopup.bodyText = "You are currently wearing the avatar that you are trying to update.

" + + "If you proceed, your avatar will be changed to the default avatar."; + lightboxPopup.button1text = "CANCEL"; + lightboxPopup.button1method = function() { + lightboxPopup.visible = false; + } + lightboxPopup.button2text = "CONFIRM"; + lightboxPopup.button2method = function() { + MyAvatar.useFullAvatarURL(''); + sendToScript(msg); + }; + lightboxPopup.visible = true; } else { sendToScript(msg); }