mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[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:
parent
bc58437e63
commit
d34683f91d
@ -55,11 +55,21 @@ const determineVisibleSearchHintOptions = (searchTerms: string, searchType: Sear
|
|||||||
const pretext = pretextArray[pretextArray.length - 1];
|
const pretext = pretextArray[pretextArray.length - 1];
|
||||||
const penultimatePretext = pretextArray[pretextArray.length - 2];
|
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) {
|
if (shouldShowHintOptions) {
|
||||||
try {
|
try {
|
||||||
newVisibleSearchHintOptions = options.filter((option) => {
|
newVisibleSearchHintOptions = options.filter((option) => {
|
||||||
|
if (pretext === '@' && option.searchTerm === 'From:') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return new RegExp(pretext, 'ig').
|
return new RegExp(pretext, 'ig').
|
||||||
test(option.searchTerm) && option.searchTerm.toLowerCase() !== pretext.toLowerCase();
|
test(option.searchTerm) && option.searchTerm.toLowerCase() !== pretext.toLowerCase();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user