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: Add action execution and rendering actions #13790

Merged
merged 18 commits into from Mar 5, 2018
Merged

Subscriptions: Add action execution and rendering actions #13790

merged 18 commits into from Mar 5, 2018

Conversation

prateekbh
Copy link
Member

  • Adds event listener for actions
  • Adds rendering logic for platforms
  • Adds methods for Subscription platform Interface

this.ampdoc_ = ampdoc;

/** @private @const */
this.document_ = this.ampdoc_.win.document;
Copy link
Contributor

Choose a reason for hiding this comment

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

You should almost never use document. Instead, there's ampdoc.getRootNode() and family.

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

const expr = candidate.getAttribute('subscriptions-display');
if (expr && evaluateExpr(expr, entitlements)) {
candidate.setAttribute('i-amphtml-subs-display', '');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If you do else {candidate.removeAttribute(...)} this method will become reentrant.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe that this should be a part of a separate deactivate method which would be called for all platforms which are not selected. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably a good idea. Feel free to proceed with that idea in a separate PR.

* @private
*/
initializeListeners_() {
this.document_.addEventListener('click', e => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto. Only add listeners to ampdoc.getRootNode()

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

const actionExecution = this.actions_.execute(action);
actionExecution.then(result => {
if (result) {
this.getEntitlements();
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this have any affect on rendering or such? Also, you may want to execute this call via the top-level service b/c changing of entitlements here could result in selecting a new platform... Maybe something like: service.reAuthorizePlatform(this) or 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.

yes, added a todo which will resolve with the actio delegation PR as both need a service interface

* Renders the UI specific to the platform
*/
render() {

Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra line

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

/**
* Renders the UI specific to the platform
*/
render() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement right away on google subscriptions: even if it's just an empty method. But I feel like the name is not broad enough. Maybe activate()?

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 d6882b2 into ampproject:master Mar 5, 2018
@prateekbh prateekbh deleted the amp-subs-action-listener branch March 5, 2018 21:15
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
…#13790)

* fix animating circle fixed position

* adding selectPlatform method

* WIP actions

* adding tests

* fixing comments

* WIP action delegation

* renders the platform actions

* adding tests

* fixing comments
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