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 origin experiments check for amp-list #20592

Merged
merged 7 commits into from
Jan 31, 2019

Conversation

cathyxz
Copy link
Contributor

@cathyxz cathyxz commented Jan 30, 2019

Adds a check to see if amp-list-load-more is within the set of origin experiments enabled for this given page. Some refactoring happened due to the fact that this check returns a promise and not a direct boolean. I debated adding a piece of code that would automatically use toggleExperiment to turn on all experiments in origin trial during runtime, but decided against this as it could inadvertently enabled experiments for all users who had once visited an origin trial page. I think a more ideal solution would be to implement a check for isOriginExperimentOn per @choumx 's original design, but I'm not sure that was ever implemented or where it should go (given the current async loading of origin-experiments-impl.js etc).

@dreamofabear
Copy link

Drive by comment on a WIP PR, but while we're in a refactor-y mood maybe we should split up amp-list which is 1K+ LOC already. 😄

@cathyxz
Copy link
Contributor Author

cathyxz commented Jan 30, 2019

I've moved about 300 LOC related to the load-more feature out of amp-list.js. But the reason it is so long is that it has a few structural problems (given what we've extended it to be used for), and many inconvenient assumptions that we cannot break due to backwards compat. The upcoming V2 is where we're hoping to address that.

@@ -156,6 +149,17 @@ export class AmpList extends AMP.BaseElement {
this.ssrTemplateHelper_ = new SsrTemplateHelper(
TAG, viewer, this.templates_);

const originTrialPromise = originExperimentsForDoc(this.getAmpDoc())
Copy link
Contributor

Choose a reason for hiding this comment

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

discussed offline but we want short-circuit and promise.resolve immediately if no load-more

@@ -0,0 +1,251 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

nice refactoring

@cathyxz cathyxz merged commit 08aebba into ampproject:master Jan 31, 2019
@cathyxz cathyxz deleted the feature/origin-trial branch January 31, 2019 18:46
nbeloglazov pushed a commit to nbeloglazov/amphtml that referenced this pull request Feb 12, 2019
* Check for origin trial experiments in amp-list

* Fix type check on origin-experiments-impl

* Whitelist origin experiments dependency check

* Refactor load more creation and show/hide logic out of amp-list

* Fix incorrect variable

* Stub getAmpDoc on the AmpDocService prototype

* Short circuit origin trial logic if no amp-list-load-more attribute
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* Check for origin trial experiments in amp-list

* Fix type check on origin-experiments-impl

* Whitelist origin experiments dependency check

* Refactor load more creation and show/hide logic out of amp-list

* Fix incorrect variable

* Stub getAmpDoc on the AmpDocService prototype

* Short circuit origin trial logic if no amp-list-load-more attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants