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

chore(core): refactor useDocumentVersion to use ListenQuery #7241

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

pedrobonamin
Copy link
Contributor

Description

refactor useDocumentVersion to use ListenQuery observable.

What to review

Testing

Existing tests updated and new tests added.

Notes for release

Copy link

vercel bot commented Jul 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 8:05am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 8:05am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 8:05am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 8:05am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 8:05am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 8:05am

Copy link
Contributor

No changes to documentation

Comment on lines 46 to 54
const state = useMemo(
() =>
versions
? (versions
.map((r) => bundles?.find((b) => r._version && getBundleSlug(r._id) === b.slug))
.filter(Boolean) as BundleDocument[])
: null,
[versions, bundles],
)
Copy link
Member

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:

Suggested change
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])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, applied, thanks!

Copy link
Member

@jordanl17 jordanl17 left a 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

@pedrobonamin pedrobonamin merged commit 95a75f4 into corel Jul 29, 2024
39 of 42 checks passed
@pedrobonamin pedrobonamin deleted the corel-77 branch July 29, 2024 08:07
bjoerge pushed a commit that referenced this pull request Jul 30, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
bjoerge pushed a commit that referenced this pull request Jul 30, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
bjoerge pushed a commit that referenced this pull request Aug 2, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
juice49 pushed a commit that referenced this pull request Aug 4, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
juice49 pushed a commit that referenced this pull request Aug 6, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
bjoerge pushed a commit that referenced this pull request Aug 7, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
bjoerge pushed a commit that referenced this pull request Aug 16, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
bjoerge pushed a commit that referenced this pull request Aug 20, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
bjoerge pushed a commit that referenced this pull request Aug 20, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
bjoerge pushed a commit that referenced this pull request Aug 20, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
RitaDias pushed a commit that referenced this pull request Aug 23, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
RitaDias pushed a commit that referenced this pull request Aug 26, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
juice49 pushed a commit that referenced this pull request Sep 3, 2024
* chore(core): refactor useDocumentVersion to use ListenQuery

* fix(core): update useDocumentVersions state
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.

None yet

2 participants