Fetch next page of facilities via infinite scroll component #750
Conversation
0fb908c
to
72e7a41
Compare
Targeted this at the marker click branch, btw, since I initially branched off that one. |
Looking at this now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation. I'm glad this was as simple as I expected, and I love a PR that adds functionality and decreases line count at the same time. I have some small questions and suggestions.
} = getState(); | ||
|
||
if (!nextPageURL) { | ||
return noop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a benefit to return noop();
instead of the equivalent return;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe they're basically equivalent insofar as each will make the return value undefined
, but I think the explicit return noop()
is a little more readable when scanning through the code.
const headerDisplayString = facilitiesCount && (facilitiesCount !== filteredFacilities.length) | ||
? `Displaying ${filteredFacilities.length} facilities of ${facilitiesCount} results` | ||
: `Displaying ${filteredFacilities.length} facilities`; | ||
const headerDisplayString = facilitiesCount && `${facilitiesCount} results`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a utility function and test in 915004a
src/app/src/util/util.js
Outdated
@@ -93,7 +91,7 @@ export const makeGetCountriesURL = () => '/api/countries/'; | |||
|
|||
export const makeGetFacilitiesURL = () => '/api/facilities/'; | |||
export const makeGetFacilityByOARIdURL = oarId => `/api/facilities/${oarId}/`; | |||
export const makeGetFacilitiesURLWithQueryString = qs => `/api/facilities/?${qs}`; | |||
export const makeGetFacilitiesURLWithQueryString = qs => `/api/facilities/?${qs}&pageSize=25`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check this literal 25
in a test so we should consider extracting it into constants.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Done in 1de1e06
error: { $set: null }, | ||
data: { | ||
features: { | ||
$set: state.facilities.data.features.concat(get(payload, 'features', [])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider
$push: get(payload, 'features', [])
Which appears to work identically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. This is
3be94f6
aae6a11
to
915004a
Compare
@jwalgran I believe this is ready for another look! |
7fe7539
to
2a87040
Compare
Adjust facilities tab so that it will fetch the next page of facilities on reaching the bottom of the infinite scroll list. Also: - remove some now unused utility code & tests - update facilities list endpoint to return results in alphabetical order - update url to retrieve facilities to request pages of 25 results at a time - add a loading indicator contextually if there's a next page of facilities to fetch
76c4b2c
to
bee55de
Compare
Squashed and rebased on develop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working perfectly, but it occurred to me that this is probably not the behavior we want when the vector tile feature flag is off
I had imagined that the entire "show arbitrary number of facilities" feature would be enabled as a whole. Do you think we could gate this new behavior with the feature flag without a burdensome amount of rewriting?
Yep, feature flagging this should be easy. In this case what I will do is just add a temporary component that is named |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for quickly implementing the feature flag. Works perfectly.
Restore the old sidebar facilities tab as a `NonVectorTileFilterSidebarFacilitiesTab` component so that it can be displayed when the vector_tile flag is off. Restore some utility functions (moved into the NonVectorTile... component) which were required to make the component work, along with some Redux actions it expected to exist. Adjust the fetchFacilities function to accept an options object so that callers can set the page request size. We don't need to make a similar adjustment to the fetchNextPage function since it uses the URL returned from the API for its next page of results.
7f44a17
to
3058053
Compare
Thanks for your help with this! |
Overview
Adjust facilities tab so that it will fetch the next page of facilities
on reaching the bottom of the infinite scroll list.
Also:
order
time
Connects #742
Notes
I'm going to make a new issue for scroll restoration. I had worked out part of a solution using a custom hook, but it's most likely an enhancement that we can address later if desired.
Testing Instructions
Checklist
fixup!
commits have been squashed