Skip to content

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

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

aleksandernsilva
Copy link
Contributor

@aleksandernsilva aleksandernsilva commented Apr 24, 2025

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 the useUnitsList hook. This change enhances type safety and integration with PaginatedSelectFiltered by updating the component's props definition with ComponentProps and Omit. Additionally, the effect for loading items and pagination logic has been streamlined.

Similarly, the AutoCompleteUnits component has been refactored to simplify its props definition using Omit and streamline data fetching by utilizing the useUnitsList hook. This refactoring removes previous dependencies and complex state management, improving the component's maintainability.

Copy link
Contributor

dionisio-bot bot commented Apr 24, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

kodus-ai bot commented Apr 24, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

Comment on lines +40 to +41
handleLoadItems(unitsList);
}, [handleLoadItems, unitsList]);
Copy link

Choose a reason for hiding this comment

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

kody code-review Potential Issues high

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 ensure unitsList is a valid array before invoking the handleLoadItems callback.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Copy link
Contributor

github-actions bot commented Apr 24, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35875/

Built to branch gh-pages at 2025-04-25 17:47 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 79.16667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 61.14%. Comparing base (a90d317) to head (81919f2).

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 57.86% <79.16%> (-0.02%) ⬇️
unit 75.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aleksandernsilva aleksandernsilva force-pushed the refactor/unit-autocomplete-query branch from 29e6950 to 20475c6 Compare April 24, 2025 20:45
Copy link

changeset-bot bot commented Apr 24, 2025

⚠️ No Changeset found

Latest commit: 7b77499

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

kodus-ai bot commented Apr 25, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@aleksandernsilva aleksandernsilva force-pushed the refactor/unit-autocomplete-query branch from 7b77499 to 81919f2 Compare April 25, 2025 17:33
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.

1 participant