-
Notifications
You must be signed in to change notification settings - Fork 427
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
fix(structure): memoize search query results #7555
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
Component Testing Report Updated Sep 30, 2024 3:22 PM (UTC) ✅ All Tests Passed -- expand for details
|
6859b0a
to
dfbe6f1
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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 great – feels so snappy and nice, and the code is much cleaner now 🙇♂️
I’ve tested the things you listed and have been trying find any cases where it doesn’t work properly, but have been unable to!
Description
This adds Stale-While-Revalidate behavior to document lists in the Studio. This means that when coming back to a previous list, we'll immediately show the last known contents, and then fetch the new version in the background. In many cases this means that going back and forth between document lists feels instant.
What to review
The actual SWR logic is implemented with an LRU cache in packages/sanity/src/structure/panes/documentList/listenSearchQuery.ts and it uses a memo key based on various input parameters for the search query request.
I took the liberty of refactoring some of the logic and renaming a few variables etc based on my (ever evolving) understanding of the existing code. Please let me know if I missed the mark on something.
Testing
I couldn't think of a good way to robustly test the SWR behavior introduced here. Let me know if you have any suggestions!
I've manually verified the following:
@hermanwikner and @robinpyon tagging you as reviewers here as well since you did the original work on doument list search including
listenSearchQuery
anduseDocumentList
.Notes for release