An ATproto social media client -- with an independent Appview.

clean up language before suggesting (#9006)

authored by samuel.fm and committed by

GitHub bbc55eb0 3e2c181c

+11 -1
+11 -1
src/view/com/composer/select-language/SuggestedLanguage.tsx
··· 1 import {useEffect, useState} from 'react' 2 import {View} from 'react-native' 3 import {msg, Trans} from '@lingui/macro' 4 import {useLingui} from '@lingui/react' 5 import lande from 'lande' ··· 21 22 export function SuggestedLanguage({ 23 text, 24 - replyToLanguage, 25 }: { 26 text: string 27 replyToLanguage?: string 28 }) { 29 const [suggestedLanguage, setSuggestedLanguage] = useState< 30 string | undefined 31 >(text.length === 0 ? replyToLanguage : undefined) ··· 125 } 126 return code3ToCode2Strict(lang) 127 }
··· 1 import {useEffect, useState} from 'react' 2 import {View} from 'react-native' 3 + import {parseLanguage} from '@atproto/api' 4 import {msg, Trans} from '@lingui/macro' 5 import {useLingui} from '@lingui/react' 6 import lande from 'lande' ··· 22 23 export function SuggestedLanguage({ 24 text, 25 + replyToLanguage: replyToLanguageProp, 26 }: { 27 text: string 28 replyToLanguage?: string 29 }) { 30 + const replyToLanguage = cleanUpLanguage(replyToLanguageProp) 31 const [suggestedLanguage, setSuggestedLanguage] = useState< 32 string | undefined 33 >(text.length === 0 ? replyToLanguage : undefined) ··· 127 } 128 return code3ToCode2Strict(lang) 129 } 130 + 131 + function cleanUpLanguage(text: string | undefined): string | undefined { 132 + if (!text) { 133 + return undefined 134 + } 135 + 136 + return parseLanguage(text)?.language 137 + }