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

Media: Fix for loading past page 1 #2314

Merged
merged 12 commits into from
Jun 17, 2020
Merged

Media: Fix for loading past page 1 #2314

merged 12 commits into from
Jun 17, 2020

Conversation

diegovar
Copy link
Contributor

@diegovar diegovar commented Jun 9, 2020

Summary

Swap useIntersectionObserver to receive a properly updated ref.

Introduced in #2069

Relevant Technical Choices

Uses an extra ref.

To-do

None.

User-facing changes

Fixes the media pane loading past page 1.

Testing Instructions

Load the story editor and scroll the media pane to load a second page. Once it loads, keep scrolling to load page 3.


Addresses #2332

Swap useIntersectionObserver to  receive a root node, not a ref.
@diegovar diegovar requested a review from merapi June 9, 2020 02:42
@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #2314 into master will increase coverage by 0.47%.
The diff coverage is 80.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2314      +/-   ##
============================================
+ Coverage     66.13%   66.61%   +0.47%     
- Complexity      314      373      +59     
============================================
  Files           651      664      +13     
  Lines         10768    11267     +499     
============================================
+ Hits           7121     7505     +384     
- Misses         3647     3762     +115     
Impacted Files Coverage Δ Complexity Δ
...ory/components/library/panes/media/mediaElement.js 49.25% <ø> (ø) 0.00 <0.00> (ø)
...-story/components/library/panes/media/mediaPane.js 78.37% <80.00%> (+0.29%) 0.00 <0.00> (ø)
...components/library/panes/animation/animationTab.js 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
...src/edit-story/components/richText/customImport.js 88.88% <0.00%> (-11.12%) 0.00% <0.00%> (ø%)
.../edit-story/components/panels/stylePreset/utils.js 93.75% <0.00%> (-6.25%) 0.00% <0.00%> (ø%)
...-story/components/canvas/canvasUploadDropTarget.js 28.57% <0.00%> (-4.77%) 0.00% <0.00%> (ø%)
assets/src/dashboard/components/button/index.js 95.83% <0.00%> (-4.17%) 0.00% <0.00%> (ø%)
...c/edit-story/components/inspector/inspectorTabs.js 17.64% <0.00%> (-3.79%) 0.00% <0.00%> (ø%)
...-story/components/canvas/singleSelectionMovable.js 47.88% <0.00%> (-2.99%) 0.00% <0.00%> (ø%)
...ews/savedTemplates/savedTemplatesGridView/index.js 83.33% <0.00%> (-2.39%) 0.00% <0.00%> (ø%)
... and 99 more

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2020

Size Change: +6.9 kB (0%)

Total Size: 837 kB

Filename Size Change
assets/js/edit-story.js 376 kB +4.23 kB (1%)
assets/js/stories-dashboard.js 444 kB +2.68 kB (0%)
ℹ️ View Unchanged
Filename Size Change
assets/css/edit-story.css 269 B 0 B
assets/css/stories-dashboard.css 305 B 0 B
assets/css/web-stories-embed-block.css 501 B 0 B
assets/js/web-stories-embed-block.js 15.7 kB 0 B

compressed-size-action

@@ -30,11 +30,7 @@ function useIntersectionEffect(ref, options = {}, handler, deps = undefined) {
useEffect(
() => {
const node = ref.current;
Copy link
Contributor

@merapi merapi Jun 9, 2020

Choose a reason for hiding this comment

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

CMIIW but options.root will always be null here, so while fetching next page works (root=window), correct root is not taken into account. Generally I think we should use ref here, we already talked about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PTAL, I took a suggestion from facebook/react#13029. It's not ideal because using a ref callback doesn't provide an easy way of passing that ref around, so I need to introduce another normal ref and set its "current" in the ref callback. Not super happy with this approach so happy to chat over slack about other suggestions you may have!

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good.
Extra useRef is not an issue for me, before that you had container, so it's the same in terms of LOC, of course we can have some kind of helper (like people do in #13029) - but not required since we don't have other places that would use it?

@swissspidy swissspidy added Group: Media Type: Bug Something isn't working labels Jun 9, 2020
@swissspidy
Copy link
Collaborator

An issue for this bug would be good so it can be appropriately sized, tracked, and QA'ed.

Copy link
Contributor

@merapi merapi left a comment

Choose a reason for hiding this comment

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

Ideally this should include Karma tests, because this part has been broken several times, making it possible is not trivial (changes in configuration so we can have variable number of elements returned from the API?) but I think we should make it happen.

@swissspidy swissspidy changed the title Fix for loading past page 1 not working introduced in #2069 Media: Fix for loading past page 1 Jun 9, 2020
@diegovar
Copy link
Contributor Author

An issue for this bug would be good so it can be appropriately sized, tracked, and QA'ed.

Done.

@diegovar diegovar requested a review from merapi June 10, 2020 04:38
@diegovar
Copy link
Contributor Author

Ideally this should include Karma tests, because this part has been broken several times, making it possible is not trivial (changes in configuration so we can have variable number of elements returned from the API?) but I think we should make it happen.

During our standup today we identified this need as well, and we'll be adding karma tests for the media pane in the following weeks.

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@merapi
Copy link
Contributor

merapi commented Jun 10, 2020

@googlebot I consent

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@merapi
Copy link
Contributor

merapi commented Jun 10, 2020

After chatting with Diego, I pushed some basic test for it, PTAL @diegovar . Optionally we can make it configurable so we can test API 500/empty state.

@diegovar
Copy link
Contributor Author

After chatting with Diego, I pushed some basic test for it, PTAL @diegovar . Optionally we can make it configurable so we can test API 500/empty state.

This is fantastic, thank you Marcin! I've left a couple of comments but looks great.

@diegovar diegovar requested a review from merapi June 10, 2020 11:49
@swissspidy
Copy link
Collaborator

@merapi could you help fix the tests here?

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@barklund
Copy link
Contributor

@googlebot I consent.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Contributor

@merapi merapi left a comment

Choose a reason for hiding this comment

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

After chatting with Dima tests are now fixed (throw in waitFor), all good.

@swissspidy
Copy link
Collaborator

This needs testing instructions in order to move forward. They're usually part of the PR template, but here it seems to have been omitted.

@merapi
Copy link
Contributor

merapi commented Jun 16, 2020

This needs testing instructions in order to move forward. They're usually part of the PR template, but here it seems to have been omitted.

Yep, leaving that to @diegovar.

@diegovar
Copy link
Contributor Author

This needs testing instructions in order to move forward. They're usually part of the PR template, but here it seems to have been omitted.

Yep, leaving that to @diegovar.

I've added testing instructions.

@swissspidy swissspidy merged commit 56fed5a into master Jun 17, 2020
@swissspidy swissspidy deleted the fix-loading-not-working branch June 17, 2020 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Media Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants