diff --git a/scripts/system/commerce/wallet.js b/scripts/system/commerce/wallet.js index afdd49c0d1..b1a00809fc 100644 --- a/scripts/system/commerce/wallet.js +++ b/scripts/system/commerce/wallet.js @@ -497,10 +497,33 @@ function walletClosed() { } function notificationDataProcessPage(data) { - return data.data.history; + return data.data.updates; // HRS FIXME .history; } var shouldShowDot = false; +function notificationPollCallbackUpdates(updatesArray) { + shouldShowDot = shouldShowDot || updatesArray.length > 0; + ui.messagesWaiting(shouldShowDot && !ui.isOpen); + + if (updatesArray.length > 0) { + var message; + if (!ui.notificationInitialCallbackMade) { + message = updatesArray.length + " of your purchased items " + + (updatesArray.length === 1 ? "has an update " : "have updates ") + + "available. Open MARKET to update."; + ui.notificationDisplayBanner(message); + + ui.notificationPollCaresAboutSince = true; + } else { + for (var i = 0; i < updatesArray.length; i++) { + message = "Update available for \"" + + updatesArray[i].base_item_title + "\"." + + "Open MARKET to update."; + ui.notificationDisplayBanner(message); + } + } + } +} function notificationPollCallback(historyArray) { if (!ui.isOpen) { var notificationCount = historyArray.length; @@ -571,12 +594,13 @@ function startup() { onOpened: walletOpened, onClosed: walletClosed, onMessage: fromQml, - notificationPollEndpoint: "/api/v1/commerce/history?per_page=10", + // How are we going to handle two polls when --limitedCommerce is false? + notificationPollEndpoint: "/api/v1/commerce/available_updates?per_page=10", // HRS FIXME "/api/v1/commerce/history?per_page=10", notificationPollTimeoutMs: 300000, notificationDataProcessPage: notificationDataProcessPage, - notificationPollCallback: notificationPollCallback, + notificationPollCallback: notificationPollCallbackUpdates, notificationPollStopPaginatingConditionMet: isReturnedDataEmpty, - notificationPollCaresAboutSince: true + notificationPollCaresAboutSince: false // HRS FIXME true }); GlobalServices.myUsernameChanged.connect(onUsernameChanged); installMarketplaceItemTester(); diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 8f334674cb..15b8c4e7cb 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -1239,12 +1239,12 @@ function startup() { home: MARKETPLACE_URL_INITIAL, onScreenChanged: onTabletScreenChanged, onMessage: onQmlMessageReceived, - notificationPollEndpoint: "/api/v1/commerce/available_updates?per_page=10", - notificationPollTimeoutMs: 300000, - notificationDataProcessPage: notificationDataProcessPage, - notificationPollCallback: notificationPollCallback, - notificationPollStopPaginatingConditionMet: isReturnedDataEmpty, - notificationPollCaresAboutSince: false // Changes to true after first poll + // notificationPollEndpoint: "/api/v1/commerce/available_updates?per_page=10", + // notificationPollTimeoutMs: 300000, + // notificationDataProcessPage: notificationDataProcessPage, + // notificationPollCallback: notificationPollCallback, + // notificationPollStopPaginatingConditionMet: isReturnedDataEmpty, + // notificationPollCaresAboutSince: false // Changes to true after first poll }); ContextOverlay.contextOverlayClicked.connect(openInspectionCertificateQML); Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);