Skip to content

✨ Implement the refresh action for amp-list#13725

Merged
dreamofabear merged 4 commits intoampproject:masterfrom
josh313:amp-list-refresh
Mar 5, 2018
Merged

✨ Implement the refresh action for amp-list#13725
dreamofabear merged 4 commits intoampproject:masterfrom
josh313:amp-list-refresh

Conversation

@josh313
Copy link
Copy Markdown
Contributor

@josh313 josh313 commented Feb 28, 2018

cc @aghassemi @choumx

@josh313 josh313 changed the title ✨ Implement the refresh action for amp-list ✨ Implement the refresh action for amp-list Feb 28, 2018

this.registerAction('refresh', () => {
this.fetchList_();
}, ActionTrust.LOW);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Curious why low trust? Do you need this to trigger on scroll?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, I don't need it to trigger on scroll. I just figured there wasn't any reason to lock it down too tightly since its not really dangerous (like a form submit or something). I can change it to ActionTrust.HIGH if you want though. It doesn't really matter to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's change to hight trust. There are two issues with low-trust:
1- Resizing logic allows amp-list to resize if it is "active" so a low-trust event from a child of amp-list can refresh and cause relayout which low-trust actions should not be able to do.
2- Even if relayout was not an issue, I like to not allow low-trust actions to trigger network requests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. I changed it to ActionTrust.HIGH now.


this.registerAction('refresh', () => {
this.fetchList_();
}, ActionTrust.LOW);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's change to hight trust. There are two issues with low-trust:
1- Resizing logic allows amp-list to resize if it is "active" so a low-trust event from a child of amp-list can refresh and cause relayout which low-trust actions should not be able to do.
2- Even if relayout was not an issue, I like to not allow low-trust actions to trigger network requests.


### Refreshing data

The `amp-list` element exposes a `refresh` action that other elements can reference in `on="tap:..."` attributes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please add this action to the master list of actions and events in https://github.com/ampproject/amphtml/blob/master/spec/amp-actions-and-events.md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

this.initialSrc_ = element.getAttribute('src');

this.registerAction('refresh', () => {
this.fetchList_();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should wrap this in if(this.layoutCompleted_){} I don't think this action should be allowed to do anything before amp-list is laidout (e.g. be used for initial load). If we need to support that use-case, there is a bit more we need to do than just call fetchList_

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Done.

@dreamofabear dreamofabear merged commit f53e339 into ampproject:master Mar 5, 2018
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
* Implement the refresh action for amp-list (ampproject#13717)

* Resolve comments from Will and Ali
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.

4 participants