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