Fix no name after @ error

This commit is contained in:
Rafael 2021-12-09 17:17:29 -03:00 committed by Thomas Zarebczan
parent a729c7ab3a
commit d51b8cc670

View file

@ -101,6 +101,7 @@ export default function TextareaWithSuggestions(props: Props) {
const suggestionTerm = suggestionValue && suggestionValue.term; const suggestionTerm = suggestionValue && suggestionValue.term;
const isEmote = suggestionValue && suggestionValue.isEmote; const isEmote = suggestionValue && suggestionValue.isEmote;
const isMention = suggestionValue && !suggestionValue.isEmote; const isMention = suggestionValue && !suggestionValue.isEmote;
const invalidTerm = suggestionTerm && isMention && suggestionTerm.charAt(1) === ':';
const additionalOptions = { isBackgroundSearch: false, [SEARCH_OPTIONS.CLAIM_TYPE]: SEARCH_OPTIONS.INCLUDE_CHANNELS }; const additionalOptions = { isBackgroundSearch: false, [SEARCH_OPTIONS.CLAIM_TYPE]: SEARCH_OPTIONS.INCLUDE_CHANNELS };
const { results, loading } = useLighthouse(debouncedTerm, showMature, SEARCH_SIZE, additionalOptions, 0); const { results, loading } = useLighthouse(debouncedTerm, showMature, SEARCH_SIZE, additionalOptions, 0);
@ -109,7 +110,7 @@ export default function TextareaWithSuggestions(props: Props) {
const hasMinLength = suggestionTerm && isMention && suggestionTerm.length >= LIGHTHOUSE_MIN_CHARACTERS; const hasMinLength = suggestionTerm && isMention && suggestionTerm.length >= LIGHTHOUSE_MIN_CHARACTERS;
const isTyping = isMention && debouncedTerm !== suggestionTerm; const isTyping = isMention && debouncedTerm !== suggestionTerm;
const showPlaceholder = const showPlaceholder =
isMention && (isTyping || loading || (results && results.length > 0 && !hasNewResolvedResults)); isMention && !invalidTerm && (isTyping || loading || (results && results.length > 0 && !hasNewResolvedResults));
const shouldFilter = (uri, previous) => uri !== canonicalCreatorUri && (!previous || !previous.includes(uri)); const shouldFilter = (uri, previous) => uri !== canonicalCreatorUri && (!previous || !previous.includes(uri));
const filteredCommentors = canonicalCommentors && canonicalCommentors.filter((uri) => shouldFilter(uri)); const filteredCommentors = canonicalCommentors && canonicalCommentors.filter((uri) => shouldFilter(uri));
@ -277,14 +278,14 @@ export default function TextareaWithSuggestions(props: Props) {
React.useEffect(() => { React.useEffect(() => {
if (!isMention) return; if (!isMention) return;
if (isTyping && suggestionTerm) { if (isTyping && suggestionTerm && !invalidTerm) {
const timer = setTimeout(() => { const timer = setTimeout(() => {
setDebouncedTerm(!hasMinLength ? '' : suggestionTerm); setDebouncedTerm(!hasMinLength ? '' : suggestionTerm);
}, INPUT_DEBOUNCE_MS); }, INPUT_DEBOUNCE_MS);
return () => clearTimeout(timer); return () => clearTimeout(timer);
} }
}, [hasMinLength, isMention, isTyping, suggestionTerm]); }, [hasMinLength, invalidTerm, isMention, isTyping, suggestionTerm]);
React.useEffect(() => { React.useEffect(() => {
if (!stringifiedResults) return; if (!stringifiedResults) return;