From d481f081bbf163086a1835e8095b5110e86a1092 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 1 Nov 2018 10:29:38 -0700 Subject: [PATCH] Fix four bugs; truncate some logs --- .../hifi/commerce/purchases/PurchasedItem.qml | 5 +-- .../qml/hifi/commerce/wallet/Wallet.qml | 6 --- .../qml/hifi/commerce/wallet/WalletHome.qml | 22 ---------- scripts/modules/appUi.js | 41 ++++++++++++------- scripts/system/commerce/wallet.js | 12 ++++++ 5 files changed, 40 insertions(+), 46 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index d13473af22..0828d86eff 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -47,8 +47,7 @@ Item { property string wornEntityID; property string upgradeUrl; property string upgradeTitle; - property bool updateAvailable: root.upgradeUrl !== "" && !root.isShowingMyItems; - property bool isShowingMyItems; + property bool updateAvailable: root.upgradeUrl !== ""; property bool valid; property string originalStatusText; @@ -231,7 +230,7 @@ Item { Loader { id: giftButton; - visible: !root.isShowingMyItems; + visible: root.itemEdition > 0; sourceComponent: contextCardButton; anchors.right: parent.right; anchors.top: parent.top; diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index e1e58bf7c7..e17faef194 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -355,10 +355,6 @@ Rectangle { if (msg.method === 'transactionHistory_usernameLinkClicked') { userInfoViewer.url = msg.usernameLink; userInfoViewer.visible = true; - } else if (msg.method === 'goToPurchases_fromWalletHome') { - root.activeView = "walletInventory"; - walletInventory.isShowingMyItems = false; - tabButtonsContainer.resetTabButtonColors(); } else { sendToScript(msg); } @@ -630,7 +626,6 @@ Rectangle { hoverEnabled: enabled; onClicked: { root.activeView = "walletInventory"; - walletInventory.isShowingMyItems = false; tabButtonsContainer.resetTabButtonColors(); } onEntered: parent.color = hifi.colors.blueHighlight; @@ -961,7 +956,6 @@ Rectangle { Commerce.getWalletStatus(); } else if (msg.referrer === 'purchases') { root.activeView = "walletInventory"; - walletInventory.isShowingMyItems = false; tabButtonsContainer.resetTabButtonColors(); } else if (msg.referrer === 'marketplace cta' || msg.referrer === 'mainPage') { sendToScript({method: 'goToMarketplaceMainPage', itemId: msg.referrer}); diff --git a/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml b/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml index 246773ff07..d32017189e 100644 --- a/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml +++ b/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml @@ -179,28 +179,6 @@ Item { color: hifi.colors.baseGrayHighlight; } - RalewaySemiBold { - id: myPurchasesLink; - text: 'Inventory'; - // Anchors - anchors.top: parent.top; - anchors.topMargin: 26; - anchors.right: parent.right; - anchors.rightMargin: 20; - width: paintedWidth; - height: 30; - y: 4; - // Text size - size: 18; - // Style - color: hifi.colors.baseGrayHighlight; - horizontalAlignment: Text.AlignRight; - - onLinkActivated: { - sendSignalToWallet({method: 'goToPurchases_fromWalletHome'}); - } - } - HifiModels.PSFListModel { id: transactionHistoryModel; property int lastPendingCount: 0; diff --git a/scripts/modules/appUi.js b/scripts/modules/appUi.js index c340dfecd2..e267293977 100644 --- a/scripts/modules/appUi.js +++ b/scripts/modules/appUi.js @@ -129,7 +129,9 @@ function AppUi(properties) { } that.isOpen = true; } - } else { // Not us. Should we do something for type Home, Menu, and particularly Closed (meaning tablet hidden? + } else { + // A different screen is now visible, or the tablet has been closed. + // Tablet visibility is controlled separately by `tabletShownChanged()` that.wireEventBridge(false); if (that.isOpen) { that.buttonActive(false); @@ -139,12 +141,12 @@ function AppUi(properties) { that.isOpen = false; } } - // console.debug(that.buttonName + " app reports: Tablet screen changed.\nNew screen type: " + type + - // "\nNew screen URL: " + url + "\nCurrent app open status: " + that.isOpen + "\n"); }; // Overwrite with the given properties: - Object.keys(properties).forEach(function (key) { that[key] = properties[key]; }); + Object.keys(properties).forEach(function (key) { + that[key] = properties[key]; + }); // // START Notification Handling @@ -157,22 +159,20 @@ function AppUi(properties) { concatenatedServerResponse[i] = new Array(); } + var MAX_LOG_LENGTH_CHARACTERS = 300; function requestCallback(error, response, optionalParams) { var indexOfRequest = optionalParams.indexOfRequest; var urlOfRequest = optionalParams.urlOfRequest; if (error || (response.status !== 'success')) { print("Error: unable to get", urlOfRequest, error || response.status); - that.notificationPollTimeout[indexOfRequest] = Script.setTimeout( - that.notificationPoll(indexOfRequest), that.notificationPollTimeoutMs[indexOfRequest]); + startNotificationTimer(indexOfRequest); return; } if (!that.notificationPollStopPaginatingConditionMet[indexOfRequest] || that.notificationPollStopPaginatingConditionMet[indexOfRequest](response)) { - that.notificationPollTimeout[indexOfRequest] = Script.setTimeout(function () { - that.notificationPoll(indexOfRequest); - }, that.notificationPollTimeoutMs[indexOfRequest]); + startNotificationTimer(indexOfRequest); var notificationData; if (concatenatedServerResponse[indexOfRequest].length) { @@ -181,7 +181,8 @@ function AppUi(properties) { notificationData = that.notificationDataProcessPage[indexOfRequest](response); } console.debug(that.buttonName, that.notificationPollEndpoint[indexOfRequest], - 'notification data for processing:', JSON.stringify(notificationData)); + 'truncated notification data for processing:', + JSON.stringify(notificationData).substring(0, MAX_LOG_LENGTH_CHARACTERS)); that.notificationPollCallback[indexOfRequest](notificationData); that.notificationInitialCallbackMade[indexOfRequest] = true; currentDataPageToRetrieve[indexOfRequest] = 1; @@ -199,15 +200,19 @@ function AppUi(properties) { var METAVERSE_BASE = Account.metaverseServerURL; + var MS_IN_SEC = 1000; that.notificationPoll = function (i) { if (!that.notificationPollEndpoint[i]) { return; } - // User is "appearing offline" or is offline - if (GlobalServices.findableBy === "none" || Account.username === "") { - that.notificationPollTimeout[i] = Script.setTimeout( - that.notificationPoll(i), that.notificationPollTimeoutMs[i]); + // User is "appearing offline" or is not logged in + if (GlobalServices.findableBy === "none" || Account.username === "Unknown user") { + // The notification polling will restart when the user changes their availability + // or when they log in, so it's not necessary to restart a timer here. + console.debug(that.buttonName + " Notifications: User is appearing offline or not logged in. " + + that.buttonName + " will poll for notifications when user logs in and has their availability " + + "set to not appear offline."); return; } @@ -217,7 +222,7 @@ function AppUi(properties) { var currentTimestamp = new Date().getTime(); var lastPollTimestamp = Settings.getValue(settingsKey, currentTimestamp); if (that.notificationPollCaresAboutSince[i]) { - url = url + "&since=" + lastPollTimestamp / 1000; + url = url + "&since=" + lastPollTimestamp / MS_IN_SEC; } Settings.setValue(settingsKey, currentTimestamp); @@ -239,6 +244,12 @@ function AppUi(properties) { that.notificationPoll(i); } + function startNotificationTimer(indexOfRequest) { + that.notificationPollTimeout[indexOfRequest] = Script.setTimeout(function () { + that.notificationPoll(indexOfRequest); + }, that.notificationPollTimeoutMs[indexOfRequest]); + } + function restartNotificationPoll() { for (var j = 0; j < that.notificationPollEndpoint.length; j++) { that.notificationInitialCallbackMade[j] = false; diff --git a/scripts/system/commerce/wallet.js b/scripts/system/commerce/wallet.js index 2ae30b5b35..bc7bccd94f 100644 --- a/scripts/system/commerce/wallet.js +++ b/scripts/system/commerce/wallet.js @@ -401,6 +401,14 @@ function openMarketplace(optionalItemOrUrl) { ui.open(url, MARKETPLACES_INJECT_SCRIPT_URL); } +function setCertificateInfo(itemCertificateId) { + ui.tablet.sendToQml({ + method: 'inspectionCertificate_setCertificateId', + entityId: "", + certificateId: itemCertificateId + }); +} + // Function Name: fromQml() // // Description: @@ -521,6 +529,9 @@ function fromQml(message) { openMarketplace(itemId); } break; + case 'purchases_itemCertificateClicked': + setCertificateInfo(message.itemCertificateId); + break; case 'clearShouldShowDotHistory': shouldShowDotHistory = false; ui.messagesWaiting(shouldShowDotUpdates || shouldShowDotHistory); @@ -698,6 +709,7 @@ function off() { Controller.mouseMoveEvent.disconnect(handleMouseMoveEvent); triggerMapping.disable(); triggerPressMapping.disable(); + isWired = false; } if (isUpdateOverlaysWired) {