[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;
|
subscription.name = subscription.fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!subscription.autoTranslate) {
|
||||||
|
subscription.autoTranslate = false;
|
||||||
|
}
|
||||||
|
|
||||||
subscription.blocker = !!subscription.blocker;
|
subscription.blocker = !!subscription.blocker;
|
||||||
subscription.blocked = !!subscription.blocked;
|
subscription.blocked = !!subscription.blocked;
|
||||||
return subscription;
|
return subscription;
|
||||||
|
|
|
@ -59,6 +59,7 @@ class AutoTranslateView extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.mounted = false;
|
||||||
this.rid = props.route.params?.rid;
|
this.rid = props.route.params?.rid;
|
||||||
const room = props.route.params?.room;
|
const room = props.route.params?.room;
|
||||||
|
|
||||||
|
@ -66,7 +67,15 @@ class AutoTranslateView extends React.Component {
|
||||||
this.roomObservable = room.observe();
|
this.roomObservable = room.observe();
|
||||||
this.subscription = this.roomObservable
|
this.subscription = this.roomObservable
|
||||||
.subscribe((changes) => {
|
.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 = {
|
this.state = {
|
||||||
|
@ -77,6 +86,7 @@ class AutoTranslateView extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
|
this.mounted = true;
|
||||||
try {
|
try {
|
||||||
const languages = await RocketChat.getSupportedLanguagesAutoTranslate();
|
const languages = await RocketChat.getSupportedLanguagesAutoTranslate();
|
||||||
this.setState({ languages });
|
this.setState({ languages });
|
||||||
|
|
Loading…
Reference in New Issue