Skip to content

Commit 43a04c6

Browse files
authored
fix(message-action-handlers): copy translated message (#3325)
## 🎯 Goal - Closes #3324 ## πŸ›  Implementation details Applies the translated message text to the clipboard if available. Otherwise, falls back to the original message text (which is the current implementation). ## πŸ§ͺ Testing While running a React Native app in development with the Metro Server, make the same edits to `node_modules/stream-chat-react-native-core/src/components/Message/hooks/useMessageActionHandlers.ts` and follow the reproduction steps in the issue. You will see that after the applied changes, the copied text matches expectations (the string the user is reading), rather than the original untranslated text. ## β˜‘οΈ Checklist - [x] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [x] PR targets the `develop` branch - [ ] Documentation is updated - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
1 parent f8c9b9a commit 43a04c6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

β€Žpackage/src/components/Message/hooks/useMessageActionHandlers.tsβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { MessageContextValue } from '../../../contexts/messageContext/Messa
77
import type { MessagesContextValue } from '../../../contexts/messagesContext/MessagesContext';
88

99
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
10+
import { useTranslatedMessage } from '../../../hooks/useTranslatedMessage';
1011
import { NativeHandlers } from '../../../native';
1112

1213
export const useMessageActionHandlers = ({
@@ -29,6 +30,7 @@ export const useMessageActionHandlers = ({
2930
Pick<MessageComposerAPIContextValue, 'setEditingState' | 'setQuotedMessage'>) => {
3031
const { t } = useTranslationContext();
3132
const handleResendMessage = () => retrySendMessage(message);
33+
const translatedMessage = useTranslatedMessage(message);
3234

3335
const handleQuotedReplyMessage = () => {
3436
setQuotedMessage(message);
@@ -42,7 +44,7 @@ export const useMessageActionHandlers = ({
4244
if (!message.text) {
4345
return;
4446
}
45-
NativeHandlers.setClipboardString(message.text);
47+
NativeHandlers.setClipboardString(translatedMessage?.text ?? message.text);
4648
};
4749

4850
const handleDeleteMessage = () => {

0 commit comments

Comments
Β (0)