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

✨ add ability for viewer to notify subscriptions that the state has changed #21720

Merged
merged 5 commits into from Apr 5, 2019

Conversation

jpettitt
Copy link
Contributor

@jpettitt jpettitt commented Apr 4, 2019

Adds a new viewer message subscriptionchange which triggers a platform reset which in turn will trigger a new getEntitlements() which will pickup whatever changed.

@@ -50,6 +50,8 @@ export class ViewerSubscriptionPlatform {

/** @const @private {!../../../src/service/viewer-impl.Viewer} */
this.viewer_ = Services.viewerForDoc(this.ampdoc_);
this.viewer_.onMessage('subscriptionchange',
Copy link
Contributor

Choose a reason for hiding this comment

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

In viewer code we so far are using "auth" terminology. E.g. "auth", 'auth-rejected', "authorization", etc. I think we should call this similarly in this case. Maybe "auth-changed"? Or "reauth"?

Otherwise, this is good. Just needs tests.

Copy link
Contributor Author

@jpettitt jpettitt Apr 4, 2019

Choose a reason for hiding this comment

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

I used subscriptionchange to match the visibilitychange naming convention used elsewhere. I can change it but I'd like to retain the subscription prefix.

Re tests I'm not really sure what to test I was looking at it - they only obvious thing would be to mock the onMessage and then call the callback and see if resetPlatforms() gets called. I'll add that. Do you see any other obvious tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Sounds good.

RE: tests - yeah, this is a pretty simple one.

@jpettitt jpettitt requested a review from dvoytenko April 5, 2019 15:52
@jpettitt jpettitt merged commit 22efc43 into ampproject:master Apr 5, 2019
@jpettitt jpettitt deleted the subscription-viewer-reset branch April 5, 2019 21:42
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