Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

dont send message if >1000 graphemes (#3995)

authored by

Samuel Newman and committed by
GitHub
5d92ac2c 27bb73c7

+19 -4
+2
src/lib/constants.ts
··· 36 36 37 37 export const MAX_GRAPHEME_LENGTH = 300 38 38 39 + export const MAX_DM_GRAPHEME_LENGTH = 1000 40 + 39 41 // Recommended is 100 per: https://www.w3.org/WAI/GL/WCAG20/tests/test3.html 40 42 // but increasing limit per user feedback 41 43 export const MAX_ALT_TEXT = 1000
+9 -3
src/screens/Messages/Conversation/MessageInput.tsx
··· 11 11 import {useSafeAreaInsets} from 'react-native-safe-area-context' 12 12 import {msg} from '@lingui/macro' 13 13 import {useLingui} from '@lingui/react' 14 + import Graphemer from 'graphemer' 14 15 15 - import {HITSLOP_10} from '#/lib/constants' 16 - import {useHaptics} from 'lib/haptics' 16 + import {HITSLOP_10, MAX_DM_GRAPHEME_LENGTH} from '#/lib/constants' 17 + import {useHaptics} from '#/lib/haptics' 18 + import * as Toast from '#/view/com/util/Toast' 17 19 import {atoms as a, useTheme} from '#/alf' 18 20 import {PaperPlane_Stroke2_Corner0_Rounded as PaperPlane} from '#/components/icons/PaperPlane' 19 21 ··· 39 41 if (message.trim() === '') { 40 42 return 41 43 } 44 + if (new Graphemer().countGraphemes(message) > MAX_DM_GRAPHEME_LENGTH) { 45 + Toast.show(_(msg`Message is too long`)) 46 + return 47 + } 42 48 onSendMessage(message.trimEnd()) 43 49 playHaptic() 44 50 setMessage('') 45 51 setTimeout(() => { 46 52 inputRef.current?.focus() 47 53 }, 100) 48 - }, [message, onSendMessage, playHaptic]) 54 + }, [message, onSendMessage, playHaptic, _]) 49 55 50 56 const onInputLayout = React.useCallback( 51 57 (e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => {
+8 -1
src/screens/Messages/Conversation/MessageInput.web.tsx
··· 2 2 import {Pressable, StyleSheet, View} from 'react-native' 3 3 import {msg} from '@lingui/macro' 4 4 import {useLingui} from '@lingui/react' 5 + import Graphemer from 'graphemer' 5 6 import TextareaAutosize from 'react-textarea-autosize' 6 7 8 + import {MAX_DM_GRAPHEME_LENGTH} from '#/lib/constants' 9 + import * as Toast from '#/view/com/util/Toast' 7 10 import {atoms as a, useTheme} from '#/alf' 8 11 import {PaperPlane_Stroke2_Corner0_Rounded as PaperPlane} from '#/components/icons/PaperPlane' 9 12 ··· 21 24 if (message.trim() === '') { 22 25 return 23 26 } 27 + if (new Graphemer().countGraphemes(message) > MAX_DM_GRAPHEME_LENGTH) { 28 + Toast.show(_(msg`Message is too long`)) 29 + return 30 + } 24 31 onSendMessage(message.trimEnd()) 25 32 setMessage('') 26 - }, [message, onSendMessage]) 33 + }, [message, onSendMessage, _]) 27 34 28 35 const onKeyDown = React.useCallback( 29 36 (e: React.KeyboardEvent<HTMLTextAreaElement>) => {