[FIX] Auto-translate feature wasn't working (#4678)
This commit is contained in:
parent
82c922fa4d
commit
b0ea5e31f8
|
@ -45,6 +45,7 @@ interface IMarkdownProps {
|
||||||
testID?: string;
|
testID?: string;
|
||||||
style?: StyleProp<TextStyle>[];
|
style?: StyleProp<TextStyle>[];
|
||||||
onLinkPress?: TOnLinkPress;
|
onLinkPress?: TOnLinkPress;
|
||||||
|
isTranslated?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TLiteral = {
|
type TLiteral = {
|
||||||
|
@ -93,9 +94,7 @@ class Markdown extends PureComponent<IMarkdownProps, any> {
|
||||||
|
|
||||||
constructor(props: IMarkdownProps) {
|
constructor(props: IMarkdownProps) {
|
||||||
super(props);
|
super(props);
|
||||||
if (!this.isNewMarkdown) {
|
this.renderer = this.createRenderer();
|
||||||
this.renderer = this.createRenderer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createRenderer = () =>
|
createRenderer = () =>
|
||||||
|
@ -310,13 +309,24 @@ class Markdown extends PureComponent<IMarkdownProps, any> {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { msg, md, mentions, channels, navToRoomInfo, useRealName, username = '', getCustomEmoji, onLinkPress } = this.props;
|
const {
|
||||||
|
msg,
|
||||||
|
md,
|
||||||
|
mentions,
|
||||||
|
channels,
|
||||||
|
navToRoomInfo,
|
||||||
|
useRealName,
|
||||||
|
username = '',
|
||||||
|
getCustomEmoji,
|
||||||
|
onLinkPress,
|
||||||
|
isTranslated
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isNewMarkdown) {
|
if (this.isNewMarkdown && !isTranslated) {
|
||||||
return (
|
return (
|
||||||
<NewMarkdown
|
<NewMarkdown
|
||||||
username={username}
|
username={username}
|
||||||
|
|
|
@ -64,6 +64,7 @@ const Content = React.memo(
|
||||||
useRealName={props.useRealName}
|
useRealName={props.useRealName}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
onLinkPress={onLinkPress}
|
onLinkPress={onLinkPress}
|
||||||
|
isTranslated={props.isTranslated}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,10 +376,13 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
|
||||||
} = item;
|
} = item;
|
||||||
|
|
||||||
let message = msg;
|
let message = msg;
|
||||||
|
let isTranslated = false;
|
||||||
// "autoTranslateRoom" and "autoTranslateLanguage" are properties from the subscription
|
// "autoTranslateRoom" and "autoTranslateLanguage" are properties from the subscription
|
||||||
// "autoTranslateMessage" is a toggle between "View Original" and "Translate" state
|
// "autoTranslateMessage" is a toggle between "View Original" and "Translate" state
|
||||||
if (autoTranslateRoom && autoTranslateMessage && autoTranslateLanguage) {
|
if (autoTranslateRoom && autoTranslateMessage && autoTranslateLanguage) {
|
||||||
message = getMessageTranslation(item, autoTranslateLanguage) || message;
|
const messageTranslated = getMessageTranslation(item, autoTranslateLanguage);
|
||||||
|
isTranslated = !!messageTranslated;
|
||||||
|
message = messageTranslated || message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -455,6 +458,7 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
|
||||||
blockAction={blockAction}
|
blockAction={blockAction}
|
||||||
highlighted={highlighted}
|
highlighted={highlighted}
|
||||||
comment={comment}
|
comment={comment}
|
||||||
|
isTranslated={isTranslated}
|
||||||
/>
|
/>
|
||||||
</MessageContext.Provider>
|
</MessageContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -63,6 +63,7 @@ export interface IMessageContent {
|
||||||
comment?: string;
|
comment?: string;
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
isHeader: boolean;
|
isHeader: boolean;
|
||||||
|
isTranslated: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMessageEmoji {
|
export interface IMessageEmoji {
|
||||||
|
|
Loading…
Reference in New Issue