From 33f5aa154457fb62099e56716ca5ae45feb98730 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 14 May 2021 17:50:36 -0400 Subject: linted --- src/components/comments/MentionInputControlled.tsx | 97 +++++++++++----------- 1 file changed, 50 insertions(+), 47 deletions(-) (limited to 'src/components/comments') diff --git a/src/components/comments/MentionInputControlled.tsx b/src/components/comments/MentionInputControlled.tsx index 6abcb566..2fd2b41d 100644 --- a/src/components/comments/MentionInputControlled.tsx +++ b/src/components/comments/MentionInputControlled.tsx @@ -6,7 +6,6 @@ import { TextInputSelectionChangeEventData, View, } from 'react-native'; - import { MentionInputProps, MentionPartType, @@ -43,16 +42,16 @@ const MentionInputControlled: FC = ({ const validRegex = () => { if (partTypes.length === 0) { - return /.*\@[^ ]*$/; + return /.*@[^ ]*$/; } else { - return new RegExp(`.*\@${keywordByTrigger[partTypes[0].trigger]}.*$`); + return new RegExp(`.*@${keywordByTrigger[partTypes[0].trigger]}.*$`); } }; - const {plainText, parts} = useMemo(() => parseValue(value, partTypes), [ - value, - partTypes, - ]); + const {plainText, parts} = useMemo( + () => parseValue(value, partTypes), + [value, partTypes], + ); const handleSelectionChange = ( event: NativeSyntheticEvent, @@ -91,36 +90,35 @@ const MentionInputControlled: FC = ({ * - Get updated value * - Trigger onChange callback with new value */ - const onSuggestionPress = (mentionType: MentionPartType) => ( - suggestion: Suggestion, - ) => { - const newValue = generateValueWithAddedSuggestion( - parts, - mentionType, - plainText, - selection, - suggestion, - ); - - if (!newValue) { - return; - } + const onSuggestionPress = + (mentionType: MentionPartType) => (suggestion: Suggestion) => { + const newValue = generateValueWithAddedSuggestion( + parts, + mentionType, + plainText, + selection, + suggestion, + ); + + if (!newValue) { + return; + } - onChange(newValue); + onChange(newValue); - /** - * Move cursor to the end of just added mention starting from trigger string and including: - * - Length of trigger string - * - Length of mention name - * - Length of space after mention (1) - * - * Not working now due to the RN bug - */ - // const newCursorPosition = currentPart.position.start + triggerPartIndex + trigger.length + - // suggestion.name.length + 1; + /** + * Move cursor to the end of just added mention starting from trigger string and including: + * - Length of trigger string + * - Length of mention name + * - Length of space after mention (1) + * + * Not working now due to the RN bug + */ + // const newCursorPosition = currentPart.position.start + triggerPartIndex + trigger.length + + // suggestion.name.length + 1; - // textInput.current?.setNativeProps({selection: {start: newCursorPosition, end: newCursorPosition}}); - }; + // textInput.current?.setNativeProps({selection: {start: newCursorPosition, end: newCursorPosition}}); + }; const handleTextInputRef = (ref: TextInput) => { textInput.current = ref as TextInput; @@ -129,7 +127,8 @@ const MentionInputControlled: FC = ({ if (typeof propInputRef === 'function') { propInputRef(ref); } else { - (propInputRef as MutableRefObject).current = ref as TextInput; + (propInputRef as MutableRefObject).current = + ref as TextInput; } } }; @@ -151,12 +150,14 @@ const MentionInputControlled: FC = ({ return ( {validateInput(keyboardText) - ? (partTypes.filter( - (one) => - isMentionPartType(one) && - one.renderSuggestions != null && - !one.isBottomMentionSuggestionsRender, - ) as MentionPartType[]).map(renderMentionSuggestions) + ? ( + partTypes.filter( + (one) => + isMentionPartType(one) && + one.renderSuggestions != null && + !one.isBottomMentionSuggestionsRender, + ) as MentionPartType[] + ).map(renderMentionSuggestions) : null} = ({ {validateInput(keyboardText) - ? (partTypes.filter( - (one) => - isMentionPartType(one) && - one.renderSuggestions != null && - one.isBottomMentionSuggestionsRender, - ) as MentionPartType[]).map(renderMentionSuggestions) + ? ( + partTypes.filter( + (one) => + isMentionPartType(one) && + one.renderSuggestions != null && + one.isBottomMentionSuggestionsRender, + ) as MentionPartType[] + ).map(renderMentionSuggestions) : null} ); -- cgit v1.2.3-70-g09d2 From 6a74b270d24f04e36821398b83863d5b97e1b44b Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Mon, 17 May 2021 12:01:22 -0700 Subject: Fixed bugs for plus sign in profile --- src/components/comments/CommentsContainer.tsx | 2 +- src/services/UserProfileService.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/components/comments') diff --git a/src/components/comments/CommentsContainer.tsx b/src/components/comments/CommentsContainer.tsx index 595ec743..d839ef38 100644 --- a/src/components/comments/CommentsContainer.tsx +++ b/src/components/comments/CommentsContainer.tsx @@ -49,7 +49,7 @@ const CommentsContainer: React.FC = ({ count += 1 + comments[i].replies_count; } return count; - } + }; useEffect(() => { const loadComments = async () => { diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index 8b7b78e1..19d353aa 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -442,7 +442,7 @@ export const verifyExistingInformation = async ( const form = new FormData(); if (email) { form.append('email', email); - } + } if (username) { form.append('username', username); } @@ -453,7 +453,7 @@ export const verifyExistingInformation = async ( }, body: form, }); - return response.status===200; + return response.status === 200; } catch (error) { console.log(error); return false; -- cgit v1.2.3-70-g09d2