Skip to content

Commit 0e6b4c4

Browse files
committed
Merge branch 'develop' into pinned
2 parents 9ce09c9 + eefb879 commit 0e6b4c4

File tree

6 files changed

+66
-3
lines changed

6 files changed

+66
-3
lines changed

__tests__/containers/message/__snapshots__/Message.stories.storyshot

+3-1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { memo } from 'react';
2+
import { View } from 'react-native';
3+
4+
import { CustomIcon } from '../../../CustomIcon';
5+
import { useTheme } from '../../../../theme';
6+
import styles from '../../styles';
7+
8+
const Translated = memo(({ isTranslated }: { isTranslated: boolean }) => {
9+
const { colors } = useTheme();
10+
11+
if (!isTranslated) {
12+
return null;
13+
}
14+
15+
return (
16+
<View style={styles.rightIcons}>
17+
<CustomIcon name='language' size={16} color={colors.auxiliaryText} />
18+
</View>
19+
);
20+
});
21+
22+
export default Translated;

app/containers/message/Components/RightIcons/index.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Encrypted from './Encrypted';
77
import MessageError from './MessageError';
88
import Pinned from './Pinned';
99
import ReadReceipt from './ReadReceipt';
10+
import Translated from './Translated';
1011

1112
const styles = StyleSheet.create({
1213
actionIcons: {
@@ -21,15 +22,26 @@ interface IRightIcons {
2122
isReadReceiptEnabled?: boolean;
2223
unread?: boolean;
2324
hasError: boolean;
25+
isTranslated: boolean;
2426
pinned?: boolean;
2527
}
2628

27-
const RightIcons = ({ type, msg, isEdited, hasError, isReadReceiptEnabled, unread, pinned }: IRightIcons): React.ReactElement => (
29+
const RightIcons = ({
30+
type,
31+
msg,
32+
isEdited,
33+
hasError,
34+
isReadReceiptEnabled,
35+
unread,
36+
isTranslated,
37+
pinned
38+
}: IRightIcons): React.ReactElement => (
2839
<View style={styles.actionIcons}>
2940
<Pinned pinned={pinned} testID={`${msg}-pinned`} />
3041
<Encrypted type={type} />
3142
<Edited testID={`${msg}-edited`} isEdited={isEdited} />
3243
<MessageError hasError={hasError} />
44+
<Translated isTranslated={isTranslated} />
3345
<ReadReceipt isReadReceiptEnabled={isReadReceiptEnabled} unread={unread} />
3446
</View>
3547
);

app/containers/message/Message.stories.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ export const Edited = () => (
127127
</>
128128
);
129129

130+
export const Translated = () => (
131+
<>
132+
<Message msg='Message header' isTranslated />
133+
<Message msg='Message without header' isTranslated isHeader={false} />
134+
</>
135+
);
136+
130137
export const Encrypted = () => (
131138
<>
132139
<Message msg='Message' type='e2e' />
@@ -939,6 +946,7 @@ export const LongNameUser = () => (
939946
<>
940947
<Message msg={'this is a normal message'} author={longNameAuthor} />
941948
<Message msg={'Edited message'} author={longNameAuthor} isEdited />
949+
<Message msg={'Translated message'} author={longNameAuthor} isTranslated />
942950
<Message msg={'Encrypted message'} author={longNameAuthor} type={E2E_MESSAGE_TYPE} />
943951
<Message msg={'Error message'} author={longNameAuthor} hasError />
944952
<Message msg={'Message with read receipt'} author={longNameAuthor} isReadReceiptEnabled read />
@@ -947,6 +955,7 @@ export const LongNameUser = () => (
947955
msg={'Show all icons '}
948956
author={longNameAuthor}
949957
isEdited
958+
isTranslated
950959
type={E2E_MESSAGE_TYPE}
951960
hasError
952961
isReadReceiptEnabled
@@ -958,6 +967,7 @@ export const LongNameUser = () => (
958967
author={longNameAuthor}
959968
isHeader={false}
960969
isEdited
970+
isTranslated
961971
type={E2E_MESSAGE_TYPE}
962972
hasError
963973
isReadReceiptEnabled
@@ -969,6 +979,7 @@ export const LongNameUser = () => (
969979
author={longNameAuthor}
970980
isHeader={false}
971981
isEdited
982+
isTranslated
972983
type={E2E_MESSAGE_TYPE}
973984
hasError
974985
isReadReceiptEnabled

app/containers/message/Message.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const Message = React.memo((props: IMessage) => {
118118
isReadReceiptEnabled={props.isReadReceiptEnabled}
119119
unread={props.unread}
120120
pinned={props.pinned}
121+
isTranslated={props.isTranslated}
121122
/>
122123
) : null}
123124
</View>

app/containers/message/User.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,24 @@ interface IMessageUser {
6161
isReadReceiptEnabled?: boolean;
6262
unread?: boolean;
6363
pinned?: boolean;
64+
isTranslated: boolean;
6465
}
6566

6667
const User = React.memo(
67-
({ isHeader, useRealName, author, alias, ts, timeFormat, hasError, navToRoomInfo, type, isEdited, ...props }: IMessageUser) => {
68+
({
69+
isHeader,
70+
useRealName,
71+
author,
72+
alias,
73+
ts,
74+
timeFormat,
75+
hasError,
76+
navToRoomInfo,
77+
type,
78+
isEdited,
79+
isTranslated,
80+
...props
81+
}: IMessageUser) => {
6882
const { user } = useContext(MessageContext);
6983
const { colors } = useTheme();
7084

@@ -112,6 +126,7 @@ const User = React.memo(
112126
isReadReceiptEnabled={props.isReadReceiptEnabled}
113127
unread={props.unread}
114128
pinned={props.pinned}
129+
isTranslated={isTranslated}
115130
/>
116131
</View>
117132
);

0 commit comments

Comments
 (0)