-
Notifications
You must be signed in to change notification settings - Fork 414
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
chore(core): refactor useDocumentVersion to use ListenQuery #7241
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
const state = useMemo( | ||
() => | ||
versions | ||
? (versions | ||
.map((r) => bundles?.find((b) => r._version && getBundleSlug(r._id) === b.slug)) | ||
.filter(Boolean) as BundleDocument[]) | ||
: null, | ||
[versions, bundles], | ||
) |
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.
COULD:
just to improve readability with the find nested in the map, I feel this reads a little more clearly:
const state = useMemo( | |
() => | |
versions | |
? (versions | |
.map((r) => bundles?.find((b) => r._version && getBundleSlug(r._id) === b.slug)) | |
.filter(Boolean) as BundleDocument[]) | |
: null, | |
[versions, bundles], | |
) | |
const state = useMemo(() => { | |
if (!versions) return null | |
const validBundles = versions | |
.map(({_id, _version}) => { | |
if (!_version) return null | |
const bundleSlug = getBundleSlug(_id) | |
return bundles?.find((bundle) => bundle.slug === bundleSlug) || null | |
}) | |
.filter(Boolean) as BundleDocument[] | |
return validBundles | |
}, [versions, bundles]) |
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.
Good suggestion, applied, thanks!
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.
Looks great, just made one suggestion that's not blocking
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
* chore(core): refactor useDocumentVersion to use ListenQuery * fix(core): update useDocumentVersions state
Description
refactor useDocumentVersion to use
ListenQuery
observable.What to review
Testing
Existing tests updated and new tests added.
Notes for release