From 68e6142f8bdce15960da98370373ed5b5a1b1ae2 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 14 Sep 2018 15:34:00 -0700 Subject: [PATCH 01/12] Follow wallet setup referrer when autogenerating new wallet --- interface/resources/qml/hifi/commerce/wallet/Wallet.qml | 1 + interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index 65d98af234..2cfa5094b9 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -831,6 +831,7 @@ Rectangle { Commerce.getWalletAuthenticatedStatus(); // before writing security image, ensures that salt/account password is set. Commerce.chooseSecurityImage(securityImagePath); Commerce.generateKeyPair(); + followReferrer({ referrer: walletSetup.referrer }); } function addLeadingZero(n) { diff --git a/interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml b/interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml index eeecff9ad0..dc6ce45a74 100644 --- a/interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml +++ b/interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml @@ -28,7 +28,7 @@ Item { property string activeView: "step_1"; property string lastPage; property bool hasShownSecurityImageTip: false; - property string referrer; + property string referrer: ''; property string keyFilePath; property date startingTimestamp; property string setupAttemptID; From d644a639904bff90dd6bc3c5148f084851a42bcd Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 19 Sep 2018 16:00:40 -0700 Subject: [PATCH 02/12] consistent/usefull checkout flow when you don't have enough money. --- .../qml/hifi/commerce/checkout/Checkout.qml | 45 ++++++++++++------- scripts/system/marketplaces/marketplaces.js | 8 ++++ 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 4d47479589..b13f23f17d 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -552,6 +552,10 @@ Rectangle { // Alignment horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter; + onLinkActivated: { + // Only case is to go to the bank. + sendToScript({method: 'gotoBank'}); + } } } @@ -1107,25 +1111,32 @@ Rectangle { } function handleBuyAgainLogic() { - // If you can buy this item again... - if (canBuyAgain()) { - // If you can't afford another copy of the item... - if (root.balanceAfterPurchase < 0) { - // If you already own the item... - if (root.alreadyOwned) { - buyText.text = "Your Wallet does not have sufficient funds to purchase this item again."; - // Else if you don't already own the item... - } else { - buyText.text = "Your Wallet does not have sufficient funds to purchase this item."; - } - buyTextContainer.color = "#FFC3CD"; - buyTextContainer.border.color = "#F3808F"; - buyGlyph.text = hifi.glyphs.alert; - buyGlyph.size = 54; - // If you CAN afford another copy of the item... + // General rules, implemented in various scattered places in this file: + // 1. If you already own the item, a viewInMyPurchasesButton is visible, + // and the buyButton is visible (and says "Buy it again") ONLY if it is a type you canBuyAgain. + // 2. Separately, + // a. If you don't have enough money to buy, the buyText becomes visible and tells you, and the buyButton is disabled. + // b. Otherwise, if the item is a content set and you don't have rez permission, the buyText becomes visible and tells you so. + + // If you can't afford another copy of the item... + if (root.balanceAfterPurchase < 0) { + // If you already own the item... + if (!root.alreadyOwned) { + buyText.text = "Your Wallet does not have sufficient funds to purchase this item."; + // Else if you don't already own the item... + } else if (canBuyAgain()) { + buyText.text = "Your Wallet does not have sufficient funds to purchase this item again."; } else { - handleContentSets(); + buyText.text = "While you do not have sufficient funds to buy this, you already have this item." } + buyText.text += " Visit Bank of High Fidelity to get more HFC." + buyTextContainer.color = "#FFC3CD"; + buyTextContainer.border.color = "#F3808F"; + buyGlyph.text = hifi.glyphs.alert; + buyGlyph.size = 54; + // If you CAN afford another copy of the item... + } else { + handleContentSets(); } } diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 13ad1f6b69..58475d7653 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -773,6 +773,14 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) { return; } switch (message.method) { + case 'gotoBank': + ui.close(); + if (Account.metaverseServerURL.indexOf("staging") >= 0) { + Window.location = "hifi://hifiqa-master-metaverse-staging"; // So that we can test in staging. + } else { + Window.location = "hifi://BankOfHighFidelity"; + } + break; case 'purchases_openWallet': case 'checkout_openWallet': case 'checkout_setUpClicked': From e1659ed520bcad856a478ea35332d9704c4adc9b Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 26 Sep 2018 14:57:47 -0700 Subject: [PATCH 03/12] fix old bad merge, and if told referrer while already setup, follow immediately --- interface/resources/qml/hifi/commerce/wallet/Wallet.qml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index fdad664bf4..d659d7abdb 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -776,6 +776,9 @@ Rectangle { case 'updateWalletReferrer': walletSetup.referrer = message.referrer; walletChoice.referrer = message.referrer; + if (Commerce.walletStatus !== 1) { // Already set up. Do it now! + followReferrer({ referrer: walletSetup.referrer }); + } // Otherwise we'll followReferrer later. break; case 'inspectionCertificate_resetCert': // NOP @@ -837,7 +840,7 @@ Rectangle { } function followReferrer(msg) { - if (msg.referrer === '' || msg.referrer === 'marketplace cta') { + if (msg.referrer === '') { root.activeView = "initialize"; Commerce.getWalletStatus(); } else if (msg.referrer === 'purchases') { From 6fdae83f1b5865893dc6692b72ab5a4de5ab1c08 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 26 Sep 2018 14:59:53 -0700 Subject: [PATCH 04/12] fix recent refactoring bug --- scripts/modules/appUi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/modules/appUi.js b/scripts/modules/appUi.js index dab377911b..19208ba7ab 100644 --- a/scripts/modules/appUi.js +++ b/scripts/modules/appUi.js @@ -42,7 +42,7 @@ function AppUi(properties) { that.additionalAppScreens = []; that.checkIsOpen = function checkIsOpen(type, tabletUrl) { // Are we active? Value used to set isOpen. // Actual url may have prefix or suffix. - return (type === that.currentVisibleScreenType) && + return that.currentVisibleUrl && ((that.home.indexOf(that.currentVisibleUrl) > -1) || (that.additionalAppScreens.indexOf(that.currentVisibleUrl) > -1)); From 940db4f112640af0b2f7ac87075a8fbfacfe2e9d Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 26 Sep 2018 15:01:30 -0700 Subject: [PATCH 05/12] fix recently introduced bug --- scripts/system/html/js/marketplacesInject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/html/js/marketplacesInject.js b/scripts/system/html/js/marketplacesInject.js index 3239105254..88df44e503 100644 --- a/scripts/system/html/js/marketplacesInject.js +++ b/scripts/system/html/js/marketplacesInject.js @@ -96,7 +96,7 @@ }); } - var emitWalletSetupEvent = function () { + emitWalletSetupEvent = function () { EventBridge.emitWebEvent(JSON.stringify({ type: "WALLET_SETUP" })); From 6e2a7c280e18a4344e5be6c3820ad510949195c8 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 26 Sep 2018 15:21:53 -0700 Subject: [PATCH 06/12] bottleneck opening our marketplace, and make sure it sets up wallet first --- scripts/system/marketplaces/marketplaces.js | 78 ++++++++++++++++----- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 58475d7653..67ed78305c 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -87,6 +87,47 @@ function setTabletVisibleInSecondaryCamera(visibleInSecondaryCam) { function openWallet() { ui.open(MARKETPLACE_WALLET_QML_PATH); } +function setupWallet(cta) { + // Needs to be done within the QML page in order to get access to QmlCommerce + openWallet(); + var ALLOWANCE_FOR_EVENT_BRIDGE_SETUP = 0; + Script.setTimeout(function () { + ui.tablet.sendToQml({ + method: 'updateWalletReferrer', + referrer: cta + }); + }, ALLOWANCE_FOR_EVENT_BRIDGE_SETUP); +} + +function onMarketplaceOpen(cta) { + if (Account.loggedIn && walletNeedsSetup()) { + if (cta) { + setupWallet(cta); + } else { + print("WARNING: opening marketplace to", url, "without wallet setup."); + } + } +} + +function openMarketplace(optionalItemOrUrl) { + // This is a bit of a kluge, but so is the whole file. + // If given a whole path, use it with no cta. + // If given an id, build the appropriate url and use the id as the cta. + // Otherwise, use home and 'marketplace cta'. + // AND... if call onMarketplaceOpen to setupWallet if we need to. + var url = optionalItemOrUrl || MARKETPLACE_URL_INITIAL; + var cta = 'marketplace cta'; + if (optionalItemOrUrl && optionalItemOrUrl.indexOf(METAVERSE_SERVER_URL) === -1) { + cta = optionalItemOrUrl; // item id + url = MARKETPLACE_URL + '/items/' + optionalItemOrUrl; + } else if (optionalItemOrUrl) { + // A specific url. Don't attempt to set up wallet because we don't have a way to come back. + // Does that ever happen without the wallet already setup? + cta = ''; + } + onMarketplaceOpen(cta); + ui.open(url, MARKETPLACES_INJECT_SCRIPT_URL); +} // Function Name: wireQmlEventBridge() // @@ -133,11 +174,14 @@ function setCertificateInfo(currentEntityWithContextOverlay, itemCertificateId) function onUsernameChanged() { if (onMarketplaceScreen) { - ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(); } } var userHasUpdates = false; +function walletNeedsSetup() { + return Wallet.walletStatus === 1; +} function sendCommerceSettings() { ui.sendToHtml({ type: "marketplaces", @@ -145,7 +189,7 @@ function sendCommerceSettings() { data: { commerceMode: Settings.getValue("commerce", true), userIsLoggedIn: Account.loggedIn, - walletNeedsSetup: Wallet.walletStatus === 1, + walletNeedsSetup: walletNeedsSetup(), metaverseServerURL: Account.metaverseServerURL, messagesWaiting: userHasUpdates } @@ -626,6 +670,8 @@ var filterText; // Used for updating Purchases QML function onWebEventReceived(message) { message = JSON.parse(message); if (message.type === GOTO_DIRECTORY) { + // This is the chooser between marketplaces. Only OUR markteplace + // requires/makes-use-of wallet, so doesn't go through openMarketplace bottleneck. ui.open(MARKETPLACES_URL, MARKETPLACES_INJECT_SCRIPT_URL); } else if (message.type === QUERY_CAN_WRITE_ASSETS) { ui.sendToHtml(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets()); @@ -667,12 +713,7 @@ function onWebEventReceived(message) { } else if (message.type === "LOGIN") { openLoginWindow(); } else if (message.type === "WALLET_SETUP") { - wireQmlEventBridge(true); - ui.tablet.sendToQml({ - method: 'updateWalletReferrer', - referrer: "marketplace cta" - }); - openWallet(); + setupWallet('marketplace cta'); } else if (message.type === "MY_ITEMS") { referrerURL = MARKETPLACE_URL_INITIAL; filterText = ""; @@ -803,7 +844,7 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) { openWallet(); break; case 'checkout_cancelClicked': - ui.open(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(message.params); break; case 'header_goToPurchases': case 'checkout_goToPurchases': @@ -812,15 +853,15 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) { ui.open(MARKETPLACE_PURCHASES_QML_PATH); break; case 'checkout_itemLinkClicked': - ui.open(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(message.itemId); break; case 'checkout_continueShopping': - ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(); break; case 'purchases_itemInfoClicked': var itemId = message.itemId; if (itemId && itemId !== "") { - ui.open(MARKETPLACE_URL + '/items/' + itemId, MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(itemId); } break; case 'checkout_rezClicked': @@ -829,20 +870,20 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) { break; case 'header_marketplaceImageClicked': case 'purchases_backClicked': - ui.open(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(message.referrerURL); break; case 'purchases_goToMarketplaceClicked': - ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(); break; case 'updateItemClicked': - ui.open(message.upgradeUrl + "?edition=" + message.itemEdition, - MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(message.upgradeUrl + "?edition=" + message.itemEdition); break; case 'giftAsset': break; case 'passphrasePopup_cancelClicked': case 'needsLogIn_cancelClicked': + // Should/must NOT check for wallet setup. ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL); break; case 'needsLogIn_loginClicked': @@ -876,7 +917,7 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) { ContextOverlay.requestOwnershipVerification(message.entity); break; case 'inspectionCertificate_showInMarketplaceClicked': - ui.open(message.marketplaceUrl, MARKETPLACES_INJECT_SCRIPT_URL); + openMarketplace(message.marketplaceUrl); break; case 'header_myItemsClicked': referrerURL = MARKETPLACE_URL_INITIAL; @@ -995,7 +1036,7 @@ var onTabletScreenChanged = function onTabletScreenChanged(type, url) { onCommerceScreen = onCommerceScreenNow; onWalletScreen = onWalletScreenNow; - wireQmlEventBridge(onMarketplaceScreen || onCommerceScreen || onWalletScreen); + wireQmlEventBridge(onCommerceScreen || onWalletScreen); if (url === MARKETPLACE_PURCHASES_QML_PATH) { ui.tablet.sendToQml({ @@ -1029,6 +1070,7 @@ var onTabletScreenChanged = function onTabletScreenChanged(type, url) { isWired = true; Wallet.refreshWalletStatus(); } else { + onMarketplaceOpen('marketplace cta'); ui.tablet.sendToQml({ method: 'inspectionCertificate_resetCert' }); From 4cf5b51124808edfc73d42c3e29010abbd991bb5 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 27 Sep 2018 15:34:16 -0700 Subject: [PATCH 07/12] works, using additional handler from wallet.js --- scripts/system/marketplaces/marketplaces.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 6bba3ce8bc..4cbc8c489a 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -93,10 +93,10 @@ function setupWallet(cta) { openWallet(); var ALLOWANCE_FOR_EVENT_BRIDGE_SETUP = 0; Script.setTimeout(function () { - ui.tablet.sendToQml({ - method: 'updateWalletReferrer', - referrer: cta - }); + ui.tablet.sendToQml({ + method: 'updateWalletReferrer', + referrer: cta + }); }, ALLOWANCE_FOR_EVENT_BRIDGE_SETUP); } @@ -126,7 +126,6 @@ function openMarketplace(optionalItemOrUrl) { // Does that ever happen without the wallet already setup? cta = ''; } - onMarketplaceOpen(cta); ui.open(url, MARKETPLACES_INJECT_SCRIPT_URL); } @@ -714,7 +713,7 @@ function onWebEventReceived(message) { } else if (message.type === "LOGIN") { openLoginWindow(); } else if (message.type === "WALLET_SETUP") { - setupWallet('marketplace cta'); + setupWallet('marketplace cta'); } else if (message.type === "MY_ITEMS") { referrerURL = MARKETPLACE_URL_INITIAL; filterText = ""; @@ -1017,6 +1016,9 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) { SEND_ASSET_PARTICLE_TIMER_UPDATE); } break; + case 'goToMarketplaceMainPage': + openMarketplace(); + break; case 'http.request': // Handled elsewhere, don't log. break; @@ -1112,7 +1114,9 @@ var onTabletScreenChanged = function onTabletScreenChanged(type, url) { isWired = true; Wallet.refreshWalletStatus(); } else { - onMarketplaceOpen('marketplace cta'); + if (onMarketplaceScreen) { + onMarketplaceOpen('marketplace cta'); + } ui.tablet.sendToQml({ method: 'inspectionCertificate_resetCert' }); From ad676b14a17334c5424284038be3291197b64d58 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 27 Sep 2018 16:06:55 -0700 Subject: [PATCH 08/12] doh - return with a newline (and no semicolon) does not continue. Don't need extra handler in marketplace any more. --- scripts/modules/appUi.js | 3 +-- scripts/system/marketplaces/marketplaces.js | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/modules/appUi.js b/scripts/modules/appUi.js index 19208ba7ab..d5ab3f32ba 100644 --- a/scripts/modules/appUi.js +++ b/scripts/modules/appUi.js @@ -42,8 +42,7 @@ function AppUi(properties) { that.additionalAppScreens = []; that.checkIsOpen = function checkIsOpen(type, tabletUrl) { // Are we active? Value used to set isOpen. // Actual url may have prefix or suffix. - return - that.currentVisibleUrl && + return that.currentVisibleUrl && ((that.home.indexOf(that.currentVisibleUrl) > -1) || (that.additionalAppScreens.indexOf(that.currentVisibleUrl) > -1)); }; diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 4cbc8c489a..f36679a4b6 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -1016,9 +1016,6 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) { SEND_ASSET_PARTICLE_TIMER_UPDATE); } break; - case 'goToMarketplaceMainPage': - openMarketplace(); - break; case 'http.request': // Handled elsewhere, don't log. break; From 75de305ec393b87159f6aefa83ca973006416612 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 27 Sep 2018 16:37:07 -0700 Subject: [PATCH 09/12] remove dead code --- interface/resources/qml/hifi/commerce/wallet/Wallet.qml | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index d659d7abdb..588b80c435 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -776,9 +776,6 @@ Rectangle { case 'updateWalletReferrer': walletSetup.referrer = message.referrer; walletChoice.referrer = message.referrer; - if (Commerce.walletStatus !== 1) { // Already set up. Do it now! - followReferrer({ referrer: walletSetup.referrer }); - } // Otherwise we'll followReferrer later. break; case 'inspectionCertificate_resetCert': // NOP From a6ef25f662643184818d036d66e744fe6840dad1 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Thu, 27 Sep 2018 18:14:16 -0700 Subject: [PATCH 10/12] just whitespace and varname changes --- scripts/system/marketplaces/marketplaces.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index b92a427c1f..dbb838664a 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -88,22 +88,22 @@ function setTabletVisibleInSecondaryCamera(visibleInSecondaryCam) { function openWallet() { ui.open(MARKETPLACE_WALLET_QML_PATH); } -function setupWallet(cta) { +function setupWallet(referrer) { // Needs to be done within the QML page in order to get access to QmlCommerce openWallet(); var ALLOWANCE_FOR_EVENT_BRIDGE_SETUP = 0; Script.setTimeout(function () { ui.tablet.sendToQml({ method: 'updateWalletReferrer', - referrer: cta + referrer: referrer }); }, ALLOWANCE_FOR_EVENT_BRIDGE_SETUP); } -function onMarketplaceOpen(cta) { +function onMarketplaceOpen(referrer) { if (Account.loggedIn && walletNeedsSetup()) { - if (cta) { - setupWallet(cta); + if (referrer) { + setupWallet(referrer); } else { print("WARNING: opening marketplace to", url, "without wallet setup."); } @@ -670,8 +670,8 @@ var filterText; // Used for updating Purchases QML function onWebEventReceived(message) { message = JSON.parse(message); if (message.type === GOTO_DIRECTORY) { - // This is the chooser between marketplaces. Only OUR markteplace - // requires/makes-use-of wallet, so doesn't go through openMarketplace bottleneck. + // This is the chooser between marketplaces. Only OUR markteplace + // requires/makes-use-of wallet, so doesn't go through openMarketplace bottleneck. ui.open(MARKETPLACES_URL, MARKETPLACES_INJECT_SCRIPT_URL); } else if (message.type === QUERY_CAN_WRITE_ASSETS) { ui.sendToHtml(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets()); @@ -822,7 +822,7 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) { } switch (message.method) { case 'gotoBank': - ui.close(); + ui.close(); if (Account.metaverseServerURL.indexOf("staging") >= 0) { Window.location = "hifi://hifiqa-master-metaverse-staging"; // So that we can test in staging. } else { From b45677cd02836167b76e31085b5768711c36d1d3 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Thu, 27 Sep 2018 19:42:01 -0700 Subject: [PATCH 11/12] additionally handle item urls (marketplace links from cert inspections) --- scripts/system/marketplaces/marketplaces.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index dbb838664a..03ce986821 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -118,13 +118,16 @@ function openMarketplace(optionalItemOrUrl) { // AND... if call onMarketplaceOpen to setupWallet if we need to. var url = optionalItemOrUrl || MARKETPLACE_URL_INITIAL; var cta = 'marketplace cta'; + var match; + // If optionalItemOrUrl contains the metaverse base, then it's a url, not an item id. if (optionalItemOrUrl && optionalItemOrUrl.indexOf(METAVERSE_SERVER_URL) === -1) { cta = optionalItemOrUrl; // item id url = MARKETPLACE_URL + '/items/' + optionalItemOrUrl; } else if (optionalItemOrUrl) { - // A specific url. Don't attempt to set up wallet because we don't have a way to come back. - // Does that ever happen without the wallet already setup? - cta = ''; + // A specific url. + match = optionalItemOrUrl.match(/\/item\/(\w+)$/); + // Don't attempt to set up wallet for a non-item url because we don't have a way to come back. + cta = (match && match[1]) || ''; } ui.open(url, MARKETPLACES_INJECT_SCRIPT_URL); } From 053f22182a1a3d759cfa017ab9fff266da4a36f7 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Fri, 28 Sep 2018 11:57:36 -0700 Subject: [PATCH 12/12] fix inspection case --- scripts/system/marketplaces/marketplaces.js | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 03ce986821..cca535a064 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -101,11 +101,19 @@ function setupWallet(referrer) { } function onMarketplaceOpen(referrer) { + var cta = referrer, match; if (Account.loggedIn && walletNeedsSetup()) { - if (referrer) { - setupWallet(referrer); + if (referrer === MARKETPLACE_URL_INITIAL) { + setupWallet('marketplace cta'); } else { - print("WARNING: opening marketplace to", url, "without wallet setup."); + match = referrer.match(/\/item\/(\w+)$/); + if (match && match[1]) { + setupWallet(match[1]); + } else if (referrer.indexOf(METAVERSE_SERVER_URL) === -1) { // not a url + setupWallet(referrer); + } else { + print("WARNING: opening marketplace to", referrer, "without wallet setup."); + } } } } @@ -117,17 +125,9 @@ function openMarketplace(optionalItemOrUrl) { // Otherwise, use home and 'marketplace cta'. // AND... if call onMarketplaceOpen to setupWallet if we need to. var url = optionalItemOrUrl || MARKETPLACE_URL_INITIAL; - var cta = 'marketplace cta'; - var match; // If optionalItemOrUrl contains the metaverse base, then it's a url, not an item id. if (optionalItemOrUrl && optionalItemOrUrl.indexOf(METAVERSE_SERVER_URL) === -1) { - cta = optionalItemOrUrl; // item id url = MARKETPLACE_URL + '/items/' + optionalItemOrUrl; - } else if (optionalItemOrUrl) { - // A specific url. - match = optionalItemOrUrl.match(/\/item\/(\w+)$/); - // Don't attempt to set up wallet for a non-item url because we don't have a way to come back. - cta = (match && match[1]) || ''; } ui.open(url, MARKETPLACES_INJECT_SCRIPT_URL); }