[FIX] The auto translate toggle don't save right state (#2142)
Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
8da50c2d73
commit
5e488972de
|
@ -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;
|
||||
|
|
|
@ -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 });
|
||||
|
|
Loading…
Reference in New Issue