Pull language methods into api context (#1847)

* Pull language methods into api context

* Rename for consistency
This commit is contained in:
Eric Bailey 2023-11-08 13:55:38 -06:00 committed by GitHub
parent f18b15241a
commit bd531f2344
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 105 additions and 93 deletions

View file

@ -53,9 +53,8 @@ import {useModals, useModalControls} from '#/state/modals'
import {useRequireAltTextEnabled} from '#/state/preferences'
import {
useLanguagePrefs,
useSetLanguagePrefs,
useLanguagePrefsApi,
toPostLanguages,
savePostLanguageToHistory,
} from '#/state/preferences/languages'
type Props = ComposerOpts
@ -73,7 +72,7 @@ export const ComposePost = observer(function ComposePost({
const store = useStores()
const requireAltTextEnabled = useRequireAltTextEnabled()
const langPrefs = useLanguagePrefs()
const setLangPrefs = useSetLanguagePrefs()
const setLangPrefs = useLanguagePrefsApi()
const textInput = useRef<TextInputRef>(null)
const [isKeyboardVisible] = useIsKeyboardVisible({iosUseWillEvents: true})
const [isProcessing, setIsProcessing] = useState(false)
@ -245,7 +244,7 @@ export const ComposePost = observer(function ComposePost({
if (!replyTo) {
store.me.mainFeed.onPostCreated()
}
savePostLanguageToHistory(setLangPrefs)
setLangPrefs.savePostLanguageToHistory()
onPost?.()
onClose()
Toast.show(`Your ${replyTo ? 'reply' : 'post'} has been published`)