#213 - feat(feedback): Reduce Frontend API calls #339
Draft
Conversation
…educe-api-calls # Conflicts: # apps/frontend/src/app/components/MapMetaData.tsx
Collaborator
Author
|
This is a draft pull request capturing work in progress during Release 3. It is not fully ready for merge, but is being documented here for transparency and potential future continuation. Next steps for this PR:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR reduces frontend API calls by caching them using react-query.
Changes Made
- Implemented useQuery to fetch and cache data on component mount, optimizing API calls by setting a 5-minute staleTime and a 10-minute cacheTime.
- Added useMutation to handle data updates and directly sync the cache using setQueryData, ensuring immediate UI updates and reducing unnecessary refetching.
Testing Instructions
Video Demo
Setting Panel API calls before react-query
SettingsNoRQ.mov
Setting Panel API calls with react-query
SettingsWithRQ.mov
AvailableDatasets API calls before react-query
AvailDatasetsNoRQ.mov
AvailableDatasets API calls with react-query
AvailDatasetsRQ.mov
Additional Notes
I ran into some issues while implementing the react-query caching in the Footer and MapMetaData components. Since we aim to complete coding ASAP, I decided to leave those out for now. However, there are still opportunities for further optimizations to reduce API calls using react-query.