Skip to content

Commit

Permalink
update implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
FitseTLT committed Jan 10, 2025
1 parent de0bd31 commit 0be72a5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/Search/SearchRouter/SearchRouterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,23 +387,23 @@ function SearchRouterList(
* Builds a suffix tree and returns a function to search in it.
*/
const filterOptions = useFastSearchFromOptions(searchOptions, {includeUserToInvite: true});
const filteredOptions = useMemo(() => filterOptions(autocompleteQueryValue), [autocompleteQueryValue, filterOptions]);

const recentReportsOptions = useMemo(() => {
const [recentReportsOptions, userToInvite] = useMemo(() => {
if (autocompleteQueryValue.trim() === '') {
return searchOptions.recentReports.slice(0, 20);
return [searchOptions.recentReports.slice(0, 20)];
}

Timing.start(CONST.TIMING.SEARCH_FILTER_OPTIONS);
const filteredOptions = filterOptions(autocompleteQueryValue);
const orderedOptions = OptionsListUtils.combineOrderingOfReportsAndPersonalDetails(filteredOptions, autocompleteQueryValue, {
sortByReportTypeInSearch: true,
preferChatroomsOverThreads: true,
});
Timing.end(CONST.TIMING.SEARCH_FILTER_OPTIONS);

const reportOptions: OptionData[] = [...orderedOptions.recentReports, ...orderedOptions.personalDetails];
return reportOptions.slice(0, 20);
}, [autocompleteQueryValue, filteredOptions, searchOptions]);
return [reportOptions.slice(0, 20), filteredOptions.userToInvite];
}, [autocompleteQueryValue, filterOptions, searchOptions]);

useEffect(() => {
ReportUserActions.searchInServer(autocompleteQueryValue.trim());
Expand All @@ -424,9 +424,8 @@ function SearchRouterList(
sections.push({title: translate('search.recentSearches'), data: recentSearchesData});
}

if (filteredOptions.userToInvite) {
const styledUserToInvite = [filteredOptions.userToInvite]?.map((item) => ({...item, pressableStyle: styles.br2, wrapperStyle: [styles.pr3, styles.pl3]}));

if (userToInvite) {
const styledUserToInvite = [userToInvite]?.map((item) => ({...item, pressableStyle: styles.br2, wrapperStyle: [styles.pr3, styles.pl3]}));
sections.push({title: undefined, data: styledUserToInvite});
}

Expand Down

0 comments on commit 0be72a5

Please sign in to comment.