Chore: Migrate SecurityPrivacyView to Typescript (#3518)
This commit is contained in:
parent
8d06b17995
commit
d83193a66d
|
@ -1,6 +1,6 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Switch } from 'react-native';
|
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 AsyncStorage from '@react-native-community/async-storage';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
|
|
||||||
|
@ -20,11 +20,15 @@ import {
|
||||||
import SafeAreaView from '../containers/SafeAreaView';
|
import SafeAreaView from '../containers/SafeAreaView';
|
||||||
import { isFDroidBuild } from '../constants/environment';
|
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 [crashReportState, setCrashReportState] = useState(getReportCrashErrorsValue());
|
||||||
const [analyticsEventsState, setAnalyticsEventsState] = useState(getReportAnalyticsEventsValue());
|
const [analyticsEventsState, setAnalyticsEventsState] = useState(getReportAnalyticsEventsValue());
|
||||||
|
|
||||||
const e2eEnabled = useSelector(state => state.settings.E2E_Enable);
|
const e2eEnabled = useSelector((state: any) => state.settings.E2E_Enable);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
|
@ -32,21 +36,22 @@ const SecurityPrivacyView = ({ navigation }) => {
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const toggleCrashReport = value => {
|
const toggleCrashReport = (value: boolean) => {
|
||||||
logEvent(events.SE_TOGGLE_CRASH_REPORT);
|
logEvent(events.SP_TOGGLE_CRASH_REPORT);
|
||||||
AsyncStorage.setItem(CRASH_REPORT_KEY, JSON.stringify(value));
|
AsyncStorage.setItem(CRASH_REPORT_KEY, JSON.stringify(value));
|
||||||
setCrashReportState(value);
|
setCrashReportState(value);
|
||||||
toggleCrashErrorsReport(value);
|
toggleCrashErrorsReport(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleAnalyticsEvents = value => {
|
const toggleAnalyticsEvents = (value: boolean) => {
|
||||||
logEvent(events.SE_TOGGLE_ANALYTICS_EVENTS);
|
logEvent(events.SP_TOGGLE_ANALYTICS_EVENTS);
|
||||||
AsyncStorage.setItem(ANALYTICS_EVENTS_KEY, JSON.stringify(value));
|
AsyncStorage.setItem(ANALYTICS_EVENTS_KEY, JSON.stringify(value));
|
||||||
setAnalyticsEventsState(value);
|
setAnalyticsEventsState(value);
|
||||||
toggleAnalyticsEventsReport(value);
|
toggleAnalyticsEventsReport(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const navigateToScreen = screen => {
|
const navigateToScreen = (screen: 'E2EEncryptionSecurityView' | 'ScreenLockConfigView') => {
|
||||||
|
// @ts-ignore
|
||||||
logEvent(events[`SP_GO_${screen.replace('View', '').toUpperCase()}`]);
|
logEvent(events[`SP_GO_${screen.replace('View', '').toUpperCase()}`]);
|
||||||
navigation.navigate(screen);
|
navigation.navigate(screen);
|
||||||
};
|
};
|
||||||
|
@ -106,8 +111,4 @@ const SecurityPrivacyView = ({ navigation }) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
SecurityPrivacyView.propTypes = {
|
|
||||||
navigation: PropTypes.object
|
|
||||||
};
|
|
||||||
|
|
||||||
export default SecurityPrivacyView;
|
export default SecurityPrivacyView;
|
Loading…
Reference in New Issue