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

IBX-5606: Removed duplicated GraphQL request in the Subitems module #765

Merged
merged 4 commits into from
May 12, 2023

Conversation

barw4
Copy link
Contributor

@barw4 barw4 commented Apr 20, 2023

Question Answer
Tickets https://issues.ibexa.co/browse/IBX-5606
Bug fix? yes
New feature? no
BC breaks? no
Tests pass? yes
Doc needed? no
License GPL-2.0

The containerResizeObserver injected into componentDidMount method actually causes double GraphQL requests. Component is immediately updated because of containerResizeObserver, hence firing componentDidUpdate method, hence second GraphQL request.

Checklist:

  • Coding standards ($ composer fix-cs)
  • Ready for Code Review

@barw4 barw4 added Bug Something isn't working Ready for review labels Apr 20, 2023
@barw4 barw4 requested review from GrabowskiM and a team April 20, 2023 14:48
@barw4 barw4 self-assigned this Apr 20, 2023
Copy link
Contributor

@dew326 dew326 left a comment

Choose a reason for hiding this comment

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

Why resizeObserver triggers loading items, it doesn't seem right in the first place. Trigger loading items on didMount sounds like proper behavior.

@barw4
Copy link
Contributor Author

barw4 commented Apr 21, 2023

@dew326 it triggers loading as observer triggers componentDidUpdate and at the point of running

        const shouldLoadPage = !activePageItems;

        if (shouldLoadPage) {
            this.loadPage(activePageIndex);
        }

in componentDidUpdate we have no active page items, hence the additional call to loadPage.

@barw4 barw4 requested a review from dew326 April 21, 2023 12:08
@dew326
Copy link
Contributor

dew326 commented Apr 21, 2023

so it should be stopped there because resize should not trigger loading items but didMount should.

Copy link
Contributor

@dew326 dew326 left a comment

Choose a reason for hiding this comment

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

the approach should be changed

@barw4 barw4 requested review from dew326 and GrabowskiM April 21, 2023 12:30
@barw4
Copy link
Contributor Author

barw4 commented Apr 21, 2023

@dew326 is this what you had in mind? f4e9dba

@dew326
Copy link
Contributor

dew326 commented Apr 21, 2023

no, I meant additional check because you probably broke pagination in this solution.

@barw4
Copy link
Contributor Author

barw4 commented Apr 21, 2023

@dew326 additional check to verify whether we are actually resizing window and not changing pagination?

@dew326
Copy link
Contributor

dew326 commented Apr 21, 2023

yes, if we resize skip loading items.

@barw4 barw4 requested a review from Gengar-i April 21, 2023 13:46
@barw4
Copy link
Contributor Author

barw4 commented Apr 21, 2023

@dew326 actually I think we are better off not updating the component every time if the size is the same. This solves the problem in the description.

@barw4 barw4 force-pushed the ibx-5606-double-subitems-fetch branch from c76ef07 to 9780461 Compare May 12, 2023 08:48
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@micszo micszo left a comment

Choose a reason for hiding this comment

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

QA Approved on Ibexa Commerce 4.4.4-dev.

@micszo micszo removed their assignment May 12, 2023
@dew326 dew326 merged commit e239916 into 4.4 May 12, 2023
@dew326 dew326 deleted the ibx-5606-double-subitems-fetch branch May 12, 2023 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working QA approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants