Only show emoji autocomplete after two typed characters (#4895)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
282f1601e3
Коммит
1539730ac1
@@ -9,7 +9,7 @@ import SuggestionStore from 'stores/suggestion_store.jsx';
|
|||||||
|
|
||||||
import Suggestion from './suggestion.jsx';
|
import Suggestion from './suggestion.jsx';
|
||||||
|
|
||||||
const MAX_EMOTICON_SUGGESTIONS = 40;
|
const MIN_EMOTICON_LENGTH = 2;
|
||||||
|
|
||||||
class EmoticonSuggestion extends Suggestion {
|
class EmoticonSuggestion extends Suggestion {
|
||||||
render() {
|
render() {
|
||||||
@@ -53,6 +53,11 @@ export default class EmoticonProvider {
|
|||||||
const text = captured[2];
|
const text = captured[2];
|
||||||
const partialName = captured[3];
|
const partialName = captured[3];
|
||||||
|
|
||||||
|
if (partialName.length < MIN_EMOTICON_LENGTH) {
|
||||||
|
SuggestionStore.clearSuggestions(suggestionId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const matched = [];
|
const matched = [];
|
||||||
|
|
||||||
// check for text emoticons if this isn't for an emoji reaction
|
// check for text emoticons if this isn't for an emoji reaction
|
||||||
@@ -70,10 +75,6 @@ export default class EmoticonProvider {
|
|||||||
for (const [name, emoji] of EmojiStore.getEmojis()) {
|
for (const [name, emoji] of EmojiStore.getEmojis()) {
|
||||||
if (name.indexOf(partialName) !== -1) {
|
if (name.indexOf(partialName) !== -1) {
|
||||||
matched.push(emoji);
|
matched.push(emoji);
|
||||||
|
|
||||||
if (matched.length >= MAX_EMOTICON_SUGGESTIONS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user