[MM-52941] Adds from: suggestion when typing @ in search (#24168)

* migrated session_length_settings, settings_group to typescript

* migrated cluster_table_container to typescript

* resolved linter and non null assertions

* fixed settings_group import

* fixed cluster_table_container import

* fixed CI CD errors

* fixed names and added in built type for license

* fixed consitency and mouse event

* fixed type annotations and imports

* added search by @

* handle case by replacing

* fixed implementation and added tests

* new implementation to search with @

* fix space

* fixed comments

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Harshal sanghvi 2023-11-14 21:08:05 +05:30 committed by GitHub
parent bc58437e63
commit d34683f91d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,11 +55,21 @@ const determineVisibleSearchHintOptions = (searchTerms: string, searchType: Sear
const pretext = pretextArray[pretextArray.length - 1];
const penultimatePretext = pretextArray[pretextArray.length - 2];
const shouldShowHintOptions = penultimatePretext ? !options.some(({searchTerm}) => penultimatePretext.toLowerCase().endsWith(searchTerm.toLowerCase())) : !options.some(({searchTerm}) => searchTerms.toLowerCase().endsWith(searchTerm.toLowerCase()));
let shouldShowHintOptions: boolean;
if (penultimatePretext) {
shouldShowHintOptions = !(options.some(({searchTerm}) => penultimatePretext.toLowerCase().endsWith(searchTerm.toLowerCase())) && penultimatePretext !== '@');
} else {
shouldShowHintOptions = !options.some(({searchTerm}) => searchTerms.toLowerCase().endsWith(searchTerm.toLowerCase())) || searchTerms === '@';
}
if (shouldShowHintOptions) {
try {
newVisibleSearchHintOptions = options.filter((option) => {
if (pretext === '@' && option.searchTerm === 'From:') {
return true;
}
return new RegExp(pretext, 'ig').
test(option.searchTerm) && option.searchTerm.toLowerCase() !== pretext.toLowerCase();
});