diff options
author | Ansh <anshnanda10@gmail.com> | 2023-06-23 10:48:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-23 12:48:52 -0500 |
commit | 08804f265e6ff8ec600295772baf8a72cbf5150d (patch) | |
tree | 1cacb5db38402483e637cb825aa5e308730804ff /src/view/com/composer/Composer.tsx | |
parent | 9b19a95e638b2a5379560b5ffb27c423ad9a2e4e (diff) | |
download | voidsky-08804f265e6ff8ec600295772baf8a72cbf5150d.tar.zst |
[APP-690] better handling of post languages language filtering (#893)
* add SelectLangBtn * memoized objects that are created to reduce re-creation on re-render * add langs when uploading post * only send the top 3 languages otherwise backend will throw error * mv ContentLanguagesSettings to folder * add post languages settings modal and state * fix typos * modify feed manip to also check langs label on post * Fix tests * Remove log * Update feed-manip.ts * Fix syntax errors * UI tuneups * Show the currently selected languages in the composer * fix linting * Use a bcp-47 matching function * Fix a duplicate language issue * Fix web * Dont include lang in prompt * Make select language btn an observer * Keep device languages on top of language selection UIs * Fix android build settings * Enforce a max of 3 languages in posts * Fix tests * Fix types --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/view/com/composer/Composer.tsx')
-rw-r--r-- | src/view/com/composer/Composer.tsx | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index f88cf4bf0..abac291a2 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -38,6 +38,7 @@ import {isDesktopWeb, isAndroid} from 'platform/detection' import {GalleryModel} from 'state/models/media/gallery' import {Gallery} from './photos/Gallery' import {MAX_GRAPHEME_LENGTH} from 'lib/constants' +import {SelectLangBtn} from './select-language/SelectLangBtn' type Props = ComposerOpts & { onClose: () => void @@ -71,6 +72,13 @@ export const ComposePost = observer(function ComposePost({ ) const insets = useSafeAreaInsets() + const viewStyles = useMemo( + () => ({ + paddingBottom: isAndroid ? insets.bottom : 0, + paddingTop: isAndroid ? insets.top : isDesktopWeb ? 0 : 15, + }), + [insets], + ) // HACK // there's a bug with @mattermost/react-native-paste-input where if the input @@ -87,6 +95,7 @@ export const ComposePost = observer(function ComposePost({ autocompleteView.setup() }, [autocompleteView]) + // listen to escape key on desktop web const onEscape = useCallback( (e: KeyboardEvent) => { if (e.key === 'Escape') { @@ -109,7 +118,6 @@ export const ComposePost = observer(function ComposePost({ }, [store, onClose], ) - useEffect(() => { if (isDesktopWeb) { window.addEventListener('keydown', onEscape) @@ -157,6 +165,7 @@ export const ComposePost = observer(function ComposePost({ extLink: extLink, onStateChange: setProcessingState, knownHandles: autocompleteView.knownHandles, + langs: store.preferences.postLanguages, }) track('Create Post', { imageCount: gallery.size, @@ -197,15 +206,13 @@ export const ComposePost = observer(function ComposePost({ ], ) - const canPost = graphemeLength <= MAX_GRAPHEME_LENGTH - - const selectTextInputPlaceholder = replyTo ? 'Write your reply' : "What's up?" + const canPost = useMemo( + () => graphemeLength <= MAX_GRAPHEME_LENGTH, + [graphemeLength], + ) + const selectTextInputPlaceholder = replyTo ? 'Write your reply' : `What's up?` - const canSelectImages = gallery.size < 4 - const viewStyles = { - paddingBottom: isAndroid ? insets.bottom : 0, - paddingTop: isAndroid ? insets.top : isDesktopWeb ? 0 : 15, - } + const canSelectImages = useMemo(() => gallery.size < 4, [gallery.size]) return ( <KeyboardAvoidingView @@ -352,6 +359,7 @@ export const ComposePost = observer(function ComposePost({ </> ) : null} <View style={s.flex1} /> + <SelectLangBtn /> <CharProgress count={graphemeLength} /> </View> </View> |