Skip to content

Commit

Permalink
Update scenic to request entitlements for showContributionOptions flow
Browse files Browse the repository at this point in the history
Make entitlements request so client config is populated before showing
contribution options.

Fixes showing Unified UI for RRM:E contributions pub.

b/279226492
  • Loading branch information
fikus committed Oct 6, 2023
1 parent 6e59d89 commit 1523d21
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {log} from './log';

log('started');

let onEntitlements = () => {};

/**
* Add subsciptions when ready.
* @param {function()} callback
Expand Down Expand Up @@ -47,7 +49,10 @@ whenReady(function (subscriptions) {
);
};
}
subscriptions.setOnEntitlementsResponse(eventCallback('entitlements'));
subscriptions.setOnEntitlementsResponse(() => {
eventCallback('entitlements');
onEntitlements(subscriptions);
});
subscriptions.setOnLinkComplete(eventCallback('link-complete'));
subscriptions.setOnLoginRequest(eventCallback('login-request'));
subscriptions.setOnSubscribeResponse(eventCallback('subscribe'));
Expand All @@ -58,8 +63,6 @@ whenReady(function (subscriptions) {
/**
* Selects the flow based on the URL query parameter.
* The query parameter is the name of the function defined in runtime.
* Defaults to 'showOffers'.
* Current valid values are: 'showOffers', 'linkAccount', 'getEntitlements'.
* @param {string} flow
* @param {...} var_args
*/
Expand Down Expand Up @@ -391,9 +394,6 @@ function setupAudienceActionsDemo(subscriptions) {
* (ex: http://localhost:8000/examples/sample-pub/1?metering)
* The query parameter is the name of the function defined in runtime.
* Defaults to 'showOffers'.
* Current valid values are: 'showOffers', 'linkAccount', 'getEntitlements',
* 'demoConsentRequired', 'demoUnknownSubscription', 'smartbutton',
* and 'updateSubscription'.
*/
function startFlowAuto() {
let flow =
Expand Down Expand Up @@ -446,6 +446,16 @@ function startFlowAuto() {
return;
}

if (flow === 'showContributionOptions') {
onEntitlements = (subscriptions) => {
subscriptions.showContributionOptions();
};
whenReady((subscriptions) => {
subscriptions.start();
});
return;
}

startFlow(flow);
}

Expand Down

0 comments on commit 1523d21

Please sign in to comment.