-
Notifications
You must be signed in to change notification settings - Fork 11.7k
refactor: Omnichannel's unit autocompletes to useInfiniteQuery #35875
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
base: develop
Are you sure you want to change the base?
Conversation
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
handleLoadItems(unitsList); | ||
}, [handleLoadItems, unitsList]); |
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.
useEffect(() => {
if (Array.isArray(unitsList)) {
handleLoadItems(unitsList);
}
}, [handleLoadItems, unitsList]);
The useEffect
hook calls handleLoadItems(unitsList)
without checking if unitsList
is a valid array, which could lead to unexpected behavior or errors if unitsList
is undefined
.
This issue appears in multiple locations:
- apps/meteor/client/omnichannel/additionalForms/AutoCompleteUnit.tsx: Lines 40-41
- apps/meteor/client/omnichannel/additionalForms/AutoCompleteUnit.tsx: Lines 40-41
- apps/meteor/client/omnichannel/additionalForms/AutoCompleteUnit.tsx: Lines 40-41
Please add a check to ensureunitsList
is a valid array before invoking thehandleLoadItems
callback.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #35875 +/- ##
===========================================
- Coverage 61.15% 61.14% -0.01%
===========================================
Files 3009 3009
Lines 71554 71549 -5
Branches 16378 16377 -1
===========================================
- Hits 43758 43750 -8
- Misses 24830 24832 +2
- Partials 2966 2967 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
29e6950
to
20475c6
Compare
|
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
7b77499
to
81919f2
Compare
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
This pull request refactors the Omnichannel unit autocomplete functionality in the Rocket.Chat repository. The changes introduce a new React hook,
useUnitsList
, which leverages@tanstack/react-query
to fetch and manage a paginated list of Omnichannel Business Units. This hook supports text filtering, an optional 'None' item, and custom limits per page.The
AutoCompleteUnit
component has been refactored to simplify its implementation by directly using theuseUnitsList
hook. This change enhances type safety and integration withPaginatedSelectFiltered
by updating the component's props definition withComponentProps
andOmit
. Additionally, the effect for loading items and pagination logic has been streamlined.Similarly, the
AutoCompleteUnits
component has been refactored to simplify its props definition usingOmit
and streamline data fetching by utilizing theuseUnitsList
hook. This refactoring removes previous dependencies and complex state management, improving the component's maintainability.