Skip to content

Show loading indicator and placeholder when an amp-list refetches#13782

Merged
aghassemi merged 18 commits intoampproject:masterfrom
josh313:amp-list-loading
Mar 20, 2018
Merged

Show loading indicator and placeholder when an amp-list refetches#13782
aghassemi merged 18 commits intoampproject:masterfrom
josh313:amp-list-loading

Conversation

@josh313
Copy link
Copy Markdown
Contributor

@josh313 josh313 commented Mar 2, 2018

cc @aghassemi @choumx

return;
}

if (state && !this.implementation_.doesReuseLoadingIndicator() &&
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.

any reason this block moved down?

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.

Not that I remember. I'm not sure how this got moved. I moved it back now.

}

/**
* Returns is reused again after the render.
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.

Returns whether loading indicator is reused...

}

/** @override */
doesReuseLoadingIndicator() {
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.

I like to suggest renaming to isLoadingReused. doesprefix is not commonly used in AMP and other related loading-related methods just say loading instead of loadingIndicator

throw user().createError('Error fetching amp-list', error);
});
})
.then(() => {
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.

nit: no new line needed here

}
}

/** @override */
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.

a bit of comment to clarify what's happening here, something along the lines of amp-list reuses the loading indicator when list is fetched again via bind mutation or refresh action

if (!this.element.getAttribute('src')) {
return Promise.resolve();
}
this.togglePlaceholder(true);
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.

This feature is technically is breaking UI change and I can see cases where one may not want this feature at all. I recommend putting this behind an attribute show-loading-on-refresh or similar. I will bring it up in our design review tomorrow morning to see what others think.

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. Let me know the outcome of the design review and I'll update the code accordingly.

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.

Added to #13718 (comment).

tl;dr: reset-on-refresh attribute needed as opt-in signal to get this behaviour.

Copy link
Copy Markdown
Contributor

@aghassemi aghassemi left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes. Few small comments and we should be good to go after.

// Hide in case fallback was displayed for a previous fetch.
this.toggleFallbackInMutate_(false);
}
this.togglePlaceholder(false);
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.

this is a change from previous code. These should happen automatically anyway. I recommend keeping the old code structure to eliminate any regressions e.g.

const fetch =...
fetch.then() {
 if(fallback) etc...
}
return fetch;

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.

You mean move this .then(...) block back to layoutCallback()? That doesn't work because then the loading and placeholder don't go away after a reload (either from the refresh action or an amp-bind change). I just tried it now.

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.

I see

this.toggleFallbackInMutate_(true);
this.togglePlaceholder(false);
} else {
throw error;
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.

ditto, if we stick with the old code structure, this should not be needed.

attrs: { name: "items" }
attrs: { name: "max-items" }
attrs: { name: "single-item" }
attrs: { name: "reset-on-refresh" }
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.

please add value="" that would ensure reset-on-refresh can not be given a value and is treated as a binary flag.
also alphabetical ordering of the attributes names

@aghassemi
Copy link
Copy Markdown
Contributor

@josh313 PR LGTM, I am gonna do some manual edge case testing and then merge it.

@aghassemi
Copy link
Copy Markdown
Contributor

@josh313 Meanwhile, could you please take a look at the failing test?

@josh313
Copy link
Copy Markdown
Contributor Author

josh313 commented Mar 13, 2018

@aghassemi Thanks. I fixed the unit tests now. The integration tests appear to have just stalled. I'm guessing that's unrelated to my change. Is there a way to restart it?

@aghassemi
Copy link
Copy Markdown
Contributor

@josh313 failure was due some whitespace nits in the validator test file. added a fix, they should pass now. I will let you know when I finish testing and merging this, will happen this week for sure.

@josh313
Copy link
Copy Markdown
Contributor Author

josh313 commented Mar 14, 2018

@aghassemi Sounds great. Thanks!

@aghassemi
Copy link
Copy Markdown
Contributor

aghassemi commented Mar 20, 2018

Rebased and did some local testing, looks good. will merge and do more testing on production sites with Canary that's cut tomorrow.

Update: (3/21)
Tests on Canary with few live sites for regression, all looks good.

@aghassemi aghassemi merged commit 0c73103 into ampproject:master Mar 20, 2018
@yajiv185
Copy link
Copy Markdown

yajiv185 commented Mar 20, 2018

@aghassemi From when we will be able to use this?

@aghassemi
Copy link
Copy Markdown
Contributor

@yajiv185 It will be in dev channel tomorrow so you can play with the feature, having your AMP pages validate with this feature is ~ 2-3 weeks away.

Gregable pushed a commit that referenced this pull request Mar 22, 2018
Gregable added a commit that referenced this pull request Mar 22, 2018
* Allow meta http-equiv=x-dns-prefetch-control

* Introduce excludes tagspec feature

* Revision bump for #13782

* Revision bump for #14040

* Revision bump for #14157,#14127
@Gregable
Copy link
Copy Markdown
Member

These validator changes will be live everywhere within an hour.

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.

5 participants