Chore: Evaluate AutoTranslate- TypeScript (#4145)

This commit is contained in:
Alex Junior 2022-05-02 14:59:49 -03:00 committed by GitHub
parent 2e8812a33e
commit 1efd6a9a65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 12 deletions

View File

@ -1,16 +1,16 @@
import React from 'react'; import React from 'react';
import { FlatList, StyleSheet, Switch } from 'react-native'; import { FlatList, StyleSheet, Switch } from 'react-native';
import { RouteProp } from '@react-navigation/core'; import { Observable, Subscription } from 'rxjs';
import { ChatsStackParamList } from '../../stacks/types'; import { ChatsStackParamList } from '../../stacks/types';
import I18n from '../../i18n'; import I18n from '../../i18n';
import StatusBar from '../../containers/StatusBar'; import StatusBar from '../../containers/StatusBar';
import * as List from '../../containers/List'; import * as List from '../../containers/List';
import { SWITCH_TRACK_COLOR, themes } from '../../lib/constants'; import { SWITCH_TRACK_COLOR, themes } from '../../lib/constants';
import { TSupportedThemes, withTheme } from '../../theme'; import { withTheme } from '../../theme';
import SafeAreaView from '../../containers/SafeAreaView'; import SafeAreaView from '../../containers/SafeAreaView';
import { events, logEvent } from '../../utils/log'; import { events, logEvent } from '../../utils/log';
import { ISubscription } from '../../definitions/ISubscription'; import { IBaseScreen, ISubscription } from '../../definitions';
import { Services } from '../../lib/services'; import { Services } from '../../lib/services';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
@ -19,22 +19,19 @@ const styles = StyleSheet.create({
} }
}); });
interface IAutoTranslateViewProps { type TAutoTranslateViewProps = IBaseScreen<ChatsStackParamList, 'AutoTranslateView'>;
route: RouteProp<ChatsStackParamList, 'AutoTranslateView'>;
theme: TSupportedThemes;
}
class AutoTranslateView extends React.Component<IAutoTranslateViewProps, any> { class AutoTranslateView extends React.Component<TAutoTranslateViewProps, any> {
static navigationOptions = () => ({ static navigationOptions = () => ({
title: I18n.t('Auto_Translate') title: I18n.t('Auto_Translate')
}); });
private mounted: boolean; private mounted: boolean;
private rid: string; private rid: string;
private roomObservable: any; private roomObservable?: Observable<ISubscription>;
private subscription: any; private subscription?: Subscription;
constructor(props: IAutoTranslateViewProps) { constructor(props: TAutoTranslateViewProps) {
super(props); super(props);
this.mounted = false; this.mounted = false;
this.rid = props.route.params?.rid ?? ''; this.rid = props.route.params?.rid ?? '';
@ -111,7 +108,7 @@ class AutoTranslateView extends React.Component<IAutoTranslateViewProps, any> {
renderIcon = () => { renderIcon = () => {
const { theme } = this.props; const { theme } = this.props;
return <List.Icon name='check' color={themes[theme!].tintColor} />; return <List.Icon name='check' color={themes[theme].tintColor} />;
}; };
renderSwitch = () => { renderSwitch = () => {