mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:58:56 +02:00
Merge pull request #14102 from howard-stearns/account-managed-wallet-punchlist2
Account-managed wallet flow improvements
This commit is contained in:
commit
878d2a6f25
6 changed files with 106 additions and 45 deletions
|
@ -552,6 +552,10 @@ Rectangle {
|
||||||
// Alignment
|
// Alignment
|
||||||
horizontalAlignment: Text.AlignLeft;
|
horizontalAlignment: Text.AlignLeft;
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
onLinkActivated: {
|
||||||
|
// Only case is to go to the bank.
|
||||||
|
sendToScript({method: 'gotoBank'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1107,25 +1111,32 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleBuyAgainLogic() {
|
function handleBuyAgainLogic() {
|
||||||
// If you can buy this item again...
|
// General rules, implemented in various scattered places in this file:
|
||||||
if (canBuyAgain()) {
|
// 1. If you already own the item, a viewInMyPurchasesButton is visible,
|
||||||
// If you can't afford another copy of the item...
|
// and the buyButton is visible (and says "Buy it again") ONLY if it is a type you canBuyAgain.
|
||||||
if (root.balanceAfterPurchase < 0) {
|
// 2. Separately,
|
||||||
// If you already own the item...
|
// a. If you don't have enough money to buy, the buyText becomes visible and tells you, and the buyButton is disabled.
|
||||||
if (root.alreadyOwned) {
|
// b. Otherwise, if the item is a content set and you don't have rez permission, the buyText becomes visible and tells you so.
|
||||||
buyText.text = "<b>Your Wallet does not have sufficient funds to purchase this item again.</b>";
|
|
||||||
// Else if you don't already own the item...
|
// If you can't afford another copy of the item...
|
||||||
} else {
|
if (root.balanceAfterPurchase < 0) {
|
||||||
buyText.text = "<b>Your Wallet does not have sufficient funds to purchase this item.</b>";
|
// If you already own the item...
|
||||||
}
|
if (!root.alreadyOwned) {
|
||||||
buyTextContainer.color = "#FFC3CD";
|
buyText.text = "<b>Your Wallet does not have sufficient funds to purchase this item.</b>";
|
||||||
buyTextContainer.border.color = "#F3808F";
|
// Else if you don't already own the item...
|
||||||
buyGlyph.text = hifi.glyphs.alert;
|
} else if (canBuyAgain()) {
|
||||||
buyGlyph.size = 54;
|
buyText.text = "<b>Your Wallet does not have sufficient funds to purchase this item again.</b>";
|
||||||
// If you CAN afford another copy of the item...
|
|
||||||
} else {
|
} else {
|
||||||
handleContentSets();
|
buyText.text = "<b>While you do not have sufficient funds to buy this, you already have this item.</b>"
|
||||||
}
|
}
|
||||||
|
buyText.text += " Visit <a href='#'>Bank of High Fidelity</a> 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -829,6 +829,7 @@ Rectangle {
|
||||||
Commerce.getWalletAuthenticatedStatus(); // before writing security image, ensures that salt/account password is set.
|
Commerce.getWalletAuthenticatedStatus(); // before writing security image, ensures that salt/account password is set.
|
||||||
Commerce.chooseSecurityImage(securityImagePath);
|
Commerce.chooseSecurityImage(securityImagePath);
|
||||||
Commerce.generateKeyPair();
|
Commerce.generateKeyPair();
|
||||||
|
followReferrer({ referrer: walletSetup.referrer });
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLeadingZero(n) {
|
function addLeadingZero(n) {
|
||||||
|
@ -836,7 +837,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
function followReferrer(msg) {
|
function followReferrer(msg) {
|
||||||
if (msg.referrer === '' || msg.referrer === 'marketplace cta') {
|
if (msg.referrer === '') {
|
||||||
root.activeView = "initialize";
|
root.activeView = "initialize";
|
||||||
Commerce.getWalletStatus();
|
Commerce.getWalletStatus();
|
||||||
} else if (msg.referrer === 'purchases') {
|
} else if (msg.referrer === 'purchases') {
|
||||||
|
|
|
@ -28,7 +28,7 @@ Item {
|
||||||
property string activeView: "step_1";
|
property string activeView: "step_1";
|
||||||
property string lastPage;
|
property string lastPage;
|
||||||
property bool hasShownSecurityImageTip: false;
|
property bool hasShownSecurityImageTip: false;
|
||||||
property string referrer;
|
property string referrer: '';
|
||||||
property string keyFilePath;
|
property string keyFilePath;
|
||||||
property date startingTimestamp;
|
property date startingTimestamp;
|
||||||
property string setupAttemptID;
|
property string setupAttemptID;
|
||||||
|
|
|
@ -42,8 +42,7 @@ function AppUi(properties) {
|
||||||
that.additionalAppScreens = [];
|
that.additionalAppScreens = [];
|
||||||
that.checkIsOpen = function checkIsOpen(type, tabletUrl) { // Are we active? Value used to set isOpen.
|
that.checkIsOpen = function checkIsOpen(type, tabletUrl) { // Are we active? Value used to set isOpen.
|
||||||
// Actual url may have prefix or suffix.
|
// Actual url may have prefix or suffix.
|
||||||
return (type === that.currentVisibleScreenType) &&
|
return that.currentVisibleUrl &&
|
||||||
that.currentVisibleUrl &&
|
|
||||||
((that.home.indexOf(that.currentVisibleUrl) > -1) ||
|
((that.home.indexOf(that.currentVisibleUrl) > -1) ||
|
||||||
(that.additionalAppScreens.indexOf(that.currentVisibleUrl) > -1));
|
(that.additionalAppScreens.indexOf(that.currentVisibleUrl) > -1));
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var emitWalletSetupEvent = function () {
|
emitWalletSetupEvent = function () {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "WALLET_SETUP"
|
type: "WALLET_SETUP"
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -88,6 +88,49 @@ function setTabletVisibleInSecondaryCamera(visibleInSecondaryCam) {
|
||||||
function openWallet() {
|
function openWallet() {
|
||||||
ui.open(MARKETPLACE_WALLET_QML_PATH);
|
ui.open(MARKETPLACE_WALLET_QML_PATH);
|
||||||
}
|
}
|
||||||
|
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: referrer
|
||||||
|
});
|
||||||
|
}, ALLOWANCE_FOR_EVENT_BRIDGE_SETUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMarketplaceOpen(referrer) {
|
||||||
|
var cta = referrer, match;
|
||||||
|
if (Account.loggedIn && walletNeedsSetup()) {
|
||||||
|
if (referrer === MARKETPLACE_URL_INITIAL) {
|
||||||
|
setupWallet('marketplace cta');
|
||||||
|
} else {
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
// If optionalItemOrUrl contains the metaverse base, then it's a url, not an item id.
|
||||||
|
if (optionalItemOrUrl && optionalItemOrUrl.indexOf(METAVERSE_SERVER_URL) === -1) {
|
||||||
|
url = MARKETPLACE_URL + '/items/' + optionalItemOrUrl;
|
||||||
|
}
|
||||||
|
ui.open(url, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
|
}
|
||||||
|
|
||||||
// Function Name: wireQmlEventBridge()
|
// Function Name: wireQmlEventBridge()
|
||||||
//
|
//
|
||||||
|
@ -134,10 +177,14 @@ function setCertificateInfo(currentEntityWithContextOverlay, itemCertificateId)
|
||||||
|
|
||||||
function onUsernameChanged() {
|
function onUsernameChanged() {
|
||||||
if (onMarketplaceScreen) {
|
if (onMarketplaceScreen) {
|
||||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function walletNeedsSetup() {
|
||||||
|
return Wallet.walletStatus === 1;
|
||||||
|
}
|
||||||
|
|
||||||
function sendCommerceSettings() {
|
function sendCommerceSettings() {
|
||||||
ui.sendToHtml({
|
ui.sendToHtml({
|
||||||
type: "marketplaces",
|
type: "marketplaces",
|
||||||
|
@ -145,7 +192,7 @@ function sendCommerceSettings() {
|
||||||
data: {
|
data: {
|
||||||
commerceMode: Settings.getValue("commerce", true),
|
commerceMode: Settings.getValue("commerce", true),
|
||||||
userIsLoggedIn: Account.loggedIn,
|
userIsLoggedIn: Account.loggedIn,
|
||||||
walletNeedsSetup: Wallet.walletStatus === 1,
|
walletNeedsSetup: walletNeedsSetup(),
|
||||||
metaverseServerURL: Account.metaverseServerURL,
|
metaverseServerURL: Account.metaverseServerURL,
|
||||||
messagesWaiting: shouldShowDot
|
messagesWaiting: shouldShowDot
|
||||||
}
|
}
|
||||||
|
@ -626,6 +673,8 @@ var filterText; // Used for updating Purchases QML
|
||||||
function onWebEventReceived(message) {
|
function onWebEventReceived(message) {
|
||||||
message = JSON.parse(message);
|
message = JSON.parse(message);
|
||||||
if (message.type === GOTO_DIRECTORY) {
|
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);
|
ui.open(MARKETPLACES_URL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
} else if (message.type === QUERY_CAN_WRITE_ASSETS) {
|
} else if (message.type === QUERY_CAN_WRITE_ASSETS) {
|
||||||
ui.sendToHtml(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
ui.sendToHtml(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
||||||
|
@ -667,12 +716,7 @@ function onWebEventReceived(message) {
|
||||||
} else if (message.type === "LOGIN") {
|
} else if (message.type === "LOGIN") {
|
||||||
openLoginWindow();
|
openLoginWindow();
|
||||||
} else if (message.type === "WALLET_SETUP") {
|
} else if (message.type === "WALLET_SETUP") {
|
||||||
wireQmlEventBridge(true);
|
setupWallet('marketplace cta');
|
||||||
ui.tablet.sendToQml({
|
|
||||||
method: 'updateWalletReferrer',
|
|
||||||
referrer: "marketplace cta"
|
|
||||||
});
|
|
||||||
openWallet();
|
|
||||||
} else if (message.type === "MY_ITEMS") {
|
} else if (message.type === "MY_ITEMS") {
|
||||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||||
filterText = "";
|
filterText = "";
|
||||||
|
@ -780,6 +824,14 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (message.method) {
|
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 'purchases_openWallet':
|
||||||
case 'checkout_openWallet':
|
case 'checkout_openWallet':
|
||||||
case 'checkout_setUpClicked':
|
case 'checkout_setUpClicked':
|
||||||
|
@ -802,7 +854,7 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
openWallet();
|
openWallet();
|
||||||
break;
|
break;
|
||||||
case 'checkout_cancelClicked':
|
case 'checkout_cancelClicked':
|
||||||
ui.open(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace(message.params);
|
||||||
break;
|
break;
|
||||||
case 'header_goToPurchases':
|
case 'header_goToPurchases':
|
||||||
case 'checkout_goToPurchases':
|
case 'checkout_goToPurchases':
|
||||||
|
@ -811,15 +863,15 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
ui.open(MARKETPLACE_PURCHASES_QML_PATH);
|
||||||
break;
|
break;
|
||||||
case 'checkout_itemLinkClicked':
|
case 'checkout_itemLinkClicked':
|
||||||
ui.open(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace(message.itemId);
|
||||||
break;
|
break;
|
||||||
case 'checkout_continueShopping':
|
case 'checkout_continueShopping':
|
||||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace();
|
||||||
break;
|
break;
|
||||||
case 'purchases_itemInfoClicked':
|
case 'purchases_itemInfoClicked':
|
||||||
var itemId = message.itemId;
|
var itemId = message.itemId;
|
||||||
if (itemId && itemId !== "") {
|
if (itemId && itemId !== "") {
|
||||||
ui.open(MARKETPLACE_URL + '/items/' + itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace(itemId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'checkout_rezClicked':
|
case 'checkout_rezClicked':
|
||||||
|
@ -840,20 +892,20 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
break;
|
break;
|
||||||
case 'header_marketplaceImageClicked':
|
case 'header_marketplaceImageClicked':
|
||||||
case 'purchases_backClicked':
|
case 'purchases_backClicked':
|
||||||
ui.open(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace(message.referrerURL);
|
||||||
break;
|
break;
|
||||||
case 'purchases_goToMarketplaceClicked':
|
case 'purchases_goToMarketplaceClicked':
|
||||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace();
|
||||||
break;
|
break;
|
||||||
case 'updateItemClicked':
|
case 'updateItemClicked':
|
||||||
ui.open(message.upgradeUrl + "?edition=" + message.itemEdition,
|
openMarketplace(message.upgradeUrl + "?edition=" + message.itemEdition);
|
||||||
MARKETPLACES_INJECT_SCRIPT_URL);
|
|
||||||
break;
|
break;
|
||||||
case 'giftAsset':
|
case 'giftAsset':
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'passphrasePopup_cancelClicked':
|
case 'passphrasePopup_cancelClicked':
|
||||||
case 'needsLogIn_cancelClicked':
|
case 'needsLogIn_cancelClicked':
|
||||||
|
// Should/must NOT check for wallet setup.
|
||||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'needsLogIn_loginClicked':
|
case 'needsLogIn_loginClicked':
|
||||||
|
@ -883,7 +935,7 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
ContextOverlay.requestOwnershipVerification(message.entity);
|
ContextOverlay.requestOwnershipVerification(message.entity);
|
||||||
break;
|
break;
|
||||||
case 'inspectionCertificate_showInMarketplaceClicked':
|
case 'inspectionCertificate_showInMarketplaceClicked':
|
||||||
ui.open(message.marketplaceUrl, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace(message.marketplaceUrl);
|
||||||
break;
|
break;
|
||||||
case 'header_myItemsClicked':
|
case 'header_myItemsClicked':
|
||||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||||
|
@ -1024,12 +1076,7 @@ var onTabletScreenChanged = function onTabletScreenChanged(type, url) {
|
||||||
onCommerceScreen = onCommerceScreenNow;
|
onCommerceScreen = onCommerceScreenNow;
|
||||||
onWalletScreen = onWalletScreenNow;
|
onWalletScreen = onWalletScreenNow;
|
||||||
onMarketplaceItemTesterScreen = onMarketplaceItemTesterScreenNow;
|
onMarketplaceItemTesterScreen = onMarketplaceItemTesterScreenNow;
|
||||||
|
wireQmlEventBridge(onCommerceScreen || onWalletScreen || onMarketplaceItemTesterScreen);
|
||||||
wireQmlEventBridge(
|
|
||||||
onMarketplaceScreen ||
|
|
||||||
onCommerceScreen ||
|
|
||||||
onWalletScreen ||
|
|
||||||
onMarketplaceItemTesterScreen);
|
|
||||||
|
|
||||||
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
|
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
|
||||||
// FIXME? Is there a race condition here in which the event
|
// FIXME? Is there a race condition here in which the event
|
||||||
|
@ -1066,6 +1113,9 @@ var onTabletScreenChanged = function onTabletScreenChanged(type, url) {
|
||||||
isWired = true;
|
isWired = true;
|
||||||
Wallet.refreshWalletStatus();
|
Wallet.refreshWalletStatus();
|
||||||
} else {
|
} else {
|
||||||
|
if (onMarketplaceScreen) {
|
||||||
|
onMarketplaceOpen('marketplace cta');
|
||||||
|
}
|
||||||
ui.tablet.sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'inspectionCertificate_resetCert'
|
method: 'inspectionCertificate_resetCert'
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue