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 "fetch-error" event for amp-list/amp-state #21512

Merged

Conversation

dreamofabear
Copy link

@dreamofabear dreamofabear commented Mar 21, 2019

Fixes #21322.

Also updates amp-viewer-assistance action handlers to such that signIn is high-trust and updateActionState is low-trust.

@dreamofabear dreamofabear changed the title Add "fetch-error" event for amp-list Add "fetch-error" event for amp-list/amp-state Mar 21, 2019
@dreamofabear dreamofabear marked this pull request as ready for review March 21, 2019 18:18
this.requestSignIn_();
if (method === 'updateActionState') {
// "updateActionState" requires a low-trust event.
if (invocation.satisfiesTrust(ActionTrust.LOW) && args) {
Copy link
Author

Choose a reason for hiding this comment

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

@hellokoji Are we sure we want to allow arbitrary arguments to updateActionState? It's more error prone due to typos for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, updateActionState takes an object parameter with an actionStatus string field and a result object field. We could make a white-list on the actionStatus string to error out quicker given an invalid argument, but for the result field, the schema can get pretty complex.

Right now we support COMPLETED_ACTION_STATUS, ACTIVE_ACTION_STATUS, and FAILED_ACTION_STATUS. I am okay with white-listing just those three.

@dreamofabear
Copy link
Author

/to @cathyxz /cc @aghassemi

@@ -461,10 +458,13 @@ export class AmpList extends AMP.BaseElement {
}

return fetch.catch(error => {
const actions = Services.actionServiceForDoc(this.element);
actions.trigger(this.element, 'fetch-error', null, ActionTrust.LOW);
Copy link
Contributor

Choose a reason for hiding this comment

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

okay that this may fire multiple times in case of infinite scroll?

  • If not, it can just be moved below if (opt_append)
  • If yes, we may wanna have an event object with more info (e.g. which load run it failed)

Copy link
Author

Choose a reason for hiding this comment

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

Yea, I think it makes more sense that way.

If yes, we may wanna have an event object with more info

Perhaps, let's wait for that FR. :)

@dreamofabear
Copy link
Author

Thanks for the reviews!

@cathyxz
Copy link
Contributor

cathyxz commented Apr 1, 2019

I think you'll need to rebase for

...Compiler issues for check-types.js:
extensions/amp-access/0.1/amp-access.js:653: ERROR - inconsistent return type
found   : undefined
required: (Promise|null)
      return;
      ^^^^^^^
1 error(s), 0 warning(s), 93.1% typed

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

5 participants