diff --git a/app/lib/methods/helpers/mergeSubscriptionsRooms.js b/app/lib/methods/helpers/mergeSubscriptionsRooms.js index 6d9f6624d..c4d3acd40 100644 --- a/app/lib/methods/helpers/mergeSubscriptionsRooms.js +++ b/app/lib/methods/helpers/mergeSubscriptionsRooms.js @@ -57,6 +57,10 @@ export const merge = (subscription, room) => { subscription.name = subscription.fname; } + if (!subscription.autoTranslate) { + subscription.autoTranslate = false; + } + subscription.blocker = !!subscription.blocker; subscription.blocked = !!subscription.blocked; return subscription; diff --git a/app/views/AutoTranslateView/index.js b/app/views/AutoTranslateView/index.js index 4cf8c4a5e..0f52db69f 100644 --- a/app/views/AutoTranslateView/index.js +++ b/app/views/AutoTranslateView/index.js @@ -59,6 +59,7 @@ class AutoTranslateView extends React.Component { constructor(props) { super(props); + this.mounted = false; this.rid = props.route.params?.rid; const room = props.route.params?.room; @@ -66,7 +67,15 @@ class AutoTranslateView extends React.Component { this.roomObservable = room.observe(); this.subscription = this.roomObservable .subscribe((changes) => { - this.room = changes; + if (this.mounted) { + const { selectedLanguage, enableAutoTranslate } = this.state; + if (selectedLanguage !== changes.autoTranslateLanguage) { + this.setState({ selectedLanguage: changes.autoTranslateLanguage }); + } + if (enableAutoTranslate !== changes.autoTranslate) { + this.setState({ enableAutoTranslate: changes.autoTranslate }); + } + } }); } this.state = { @@ -77,6 +86,7 @@ class AutoTranslateView extends React.Component { } async componentDidMount() { + this.mounted = true; try { const languages = await RocketChat.getSupportedLanguagesAutoTranslate(); this.setState({ languages });