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

Artist Auction Results App, make filter state track page number and cursor. #5648

Merged
merged 2 commits into from
May 28, 2020
Merged

Artist Auction Results App, make filter state track page number and cursor. #5648

merged 2 commits into from
May 28, 2020

Conversation

artsyjian
Copy link
Contributor

https://artsyproduct.atlassian.net/browse/PURCHASE-1927

To make filter state track current page and cursor. So that we can really rely on filter state to determine whether any filters (including page#) has changed.

In filter state, replaced page property with an object containing page and cursor. The two must be updated together due to the way Reducer works. cursor is really what is used for data fetching.

paginated state is removed. It was a work-around because filter state didn't track page (it was always 1).

The relay fetch code block in loadAfter() was required to trigger refetch due to pagination. Now it isn't anymore. Now, pagination triggers filter state difference which triggers relay fetch in useDeepCompareEffect.

@artsyjian artsyjian changed the title Artist Auction Results App, make filter state track the page number that user is on. Artist Auction Results App, make filter state track page number and cursor. May 26, 2020
@artsyjian artsyjian requested a review from jpotts244 May 26, 2020 21:30
@ArtsyOpenSource
Copy link

ArtsyOpenSource commented May 26, 2020

Fails
🚫

Danger failed to run dangerfile.ts.

Error RangeError

Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at Object.getTokenFromCode (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:3613:19)
    at Object.getTokenFromCode (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:2312:20)
    at Object.nextToken (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:6587:12)
    at Object.next (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:6527:10)
    at Object.parseLiteral (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:8999:10)
    at Object.parseExprAtom (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:8821:21)
    at Object.parseExprAtom (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:3609:20)
    at Object.parseExprSubscripts (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:8483:23)
    at Object.parseMaybeUnary (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:8463:21)
    at Object.parseExprOps (/home/circleci/project/node_modules/@babel/core/node_modules/@babel/parser/lib/index.js:8329:23)

Dangerfile

-----------------------^

Generated by 🚫 dangerJS against b18e3ac

Comment on lines -65 to -92
const loadAfter = cursor => {
setIsLoading(true)
togglePaginated(true)

relay.refetch(
{
first: PAGE_SIZE,
after: cursor,
artistID: artist.slug,
before: null,
last: null,
organizations,
categories,
sizes,
sort,
createdBeforeYear,
createdAfterYear,
allowEmptyCreatedDates,
},
null,
error => {
setIsLoading(false)

if (error) {
logger.error(error)
}
}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is such a huge improvement 🙌.

Comment on lines +186 to +188
if (filterState.pageAndCursor.page === 1) {
filterState.pageAndCursor.cursor = null
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@zephraph zephraph merged commit 31445ab into artsy:master May 28, 2020
@artsy-peril artsy-peril bot mentioned this pull request May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants