Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions: Intercept login action #15362

Merged
merged 14 commits into from May 18, 2018

Conversation

prateekbh
Copy link
Member

  • intercepts login action and delegates based on platform selection.

@prateekbh prateekbh changed the title WIP Subscriptions: Intercept login action Subscriptions: Intercept login action May 17, 2018
@prateekbh prateekbh requested a review from dvoytenko May 17, 2018 22:12
platformScores.sort(function(platform1, platform2) {
return platform2.weight - platform1.weight;
});
return platformScores[0].platform;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If none of the platforms matches viewer - would this guarantee that local wins then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a reason to do this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. With all equal "local" should win.

* @return {!Promise<!./subscription-platform.SubscriptionPlatform>}
*/
scoreBasedLogin() {
return this.platformStore_.getAllPlatforms().then(platforms => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are taking some risk here getting into popup blocker situation. What if we went synchronous here with strictly already loaded platforms? Local is always there, so we always have one option. In other words, maybe getAvailablePlatforms() method instead? Otherwise "login" is only enhanced - there's no significant change in behavior. If we fail to enhance something - it's still functional.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (element.hasAttribute('subscriptions-service')) {
if (element.getAttribute('subscriptions-service') === 'local') {
this.executeAction(action);
} else if (!element.hasAttribute('subscriptions-service')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be just easier to do if ((element.getAttribute('subscriptions-service') || 'auto') == 'auto')?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*
* @return {!Promise}
*/
login() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename to represent a bit more precisely what it does. E.g. "selectPlatformForLogin" or some such.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/**
* Returns login platform based on platform selection
*
* @return {!Promise}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!Promise<???>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, was an intermittent thing.


it('should delegate service selection to scoreBasedLogin if no service '
+ 'name is specified', () => {
element.removeAttribute('subscriptions-service');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also test "auto" value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@prateekbh prateekbh merged commit 72d2c91 into ampproject:master May 18, 2018
@prateekbh prateekbh deleted the login-intercept branch May 18, 2018 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants