Chore: Migrate SecurityPrivacyView to Typescript (#3518)

This commit is contained in:
Reinaldo Neto 2021-12-02 10:26:34 -03:00 committed by GitHub
parent 8d06b17995
commit d83193a66d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 12 deletions

View File

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { Switch } from 'react-native';
import PropTypes from 'prop-types';
import { StackNavigationProp } from '@react-navigation/stack';
import AsyncStorage from '@react-native-community/async-storage';
import { useSelector } from 'react-redux';
@ -20,11 +20,15 @@ import {
import SafeAreaView from '../containers/SafeAreaView';
import { isFDroidBuild } from '../constants/environment';
const SecurityPrivacyView = ({ navigation }) => {
interface ISecurityPrivacyViewProps {
navigation: StackNavigationProp<any, 'SecurityPrivacyView'>;
}
const SecurityPrivacyView = ({ navigation }: ISecurityPrivacyViewProps): JSX.Element => {
const [crashReportState, setCrashReportState] = useState(getReportCrashErrorsValue());
const [analyticsEventsState, setAnalyticsEventsState] = useState(getReportAnalyticsEventsValue());
const e2eEnabled = useSelector(state => state.settings.E2E_Enable);
const e2eEnabled = useSelector((state: any) => state.settings.E2E_Enable);
useEffect(() => {
navigation.setOptions({
@ -32,21 +36,22 @@ const SecurityPrivacyView = ({ navigation }) => {
});
}, []);
const toggleCrashReport = value => {
logEvent(events.SE_TOGGLE_CRASH_REPORT);
const toggleCrashReport = (value: boolean) => {
logEvent(events.SP_TOGGLE_CRASH_REPORT);
AsyncStorage.setItem(CRASH_REPORT_KEY, JSON.stringify(value));
setCrashReportState(value);
toggleCrashErrorsReport(value);
};
const toggleAnalyticsEvents = value => {
logEvent(events.SE_TOGGLE_ANALYTICS_EVENTS);
const toggleAnalyticsEvents = (value: boolean) => {
logEvent(events.SP_TOGGLE_ANALYTICS_EVENTS);
AsyncStorage.setItem(ANALYTICS_EVENTS_KEY, JSON.stringify(value));
setAnalyticsEventsState(value);
toggleAnalyticsEventsReport(value);
};
const navigateToScreen = screen => {
const navigateToScreen = (screen: 'E2EEncryptionSecurityView' | 'ScreenLockConfigView') => {
// @ts-ignore
logEvent(events[`SP_GO_${screen.replace('View', '').toUpperCase()}`]);
navigation.navigate(screen);
};
@ -106,8 +111,4 @@ const SecurityPrivacyView = ({ navigation }) => {
);
};
SecurityPrivacyView.propTypes = {
navigation: PropTypes.object
};
export default SecurityPrivacyView;