Chore: Migrate UserPreserencesView to Typescript

* chore: migrate the view UserPrederencesView to ts

Co-authored-by: Natilorens <nathalialorenacardoso@gmail.com>

* minor tweak

Co-authored-by: FranciscoHeronildo <heronildo.2010@hotmail.com>
Co-authored-by: Natilorens <nathalialorenacardoso@gmail.com>
Co-authored-by: AlexAlexandre <alexalexandrejr@gmail.com>
This commit is contained in:
Reinaldo Neto 2021-11-10 15:43:35 -03:00 committed by GitHub
parent 0600c091d3
commit a6e87c1236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View File

@ -155,6 +155,9 @@ export default {
SE_CLEAR_LOCAL_SERVER_CACHE: 'se_clear_local_server_cache', SE_CLEAR_LOCAL_SERVER_CACHE: 'se_clear_local_server_cache',
SE_LOG_OUT: 'se_log_out', SE_LOG_OUT: 'se_log_out',
// USER PREFERENCE VIEW
UP_GO_USER_NOTIFICATION_PREF: 'up_go_user_notification_pref',
// SECURITY PRIVACY VIEW // SECURITY PRIVACY VIEW
SP_GO_E2EENCRYPTIONSECURITY: 'sp_go_e2e_encryption_security', SP_GO_E2EENCRYPTIONSECURITY: 'sp_go_e2e_encryption_security',
SP_GO_SCREENLOCKCONFIG: 'sp_go_screen_lock_cfg', SP_GO_SCREENLOCKCONFIG: 'sp_go_screen_lock_cfg',

View File

@ -1,6 +1,6 @@
import { StackNavigationProp } from '@react-navigation/stack';
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 { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import I18n from '../../i18n'; import I18n from '../../i18n';
@ -12,7 +12,11 @@ import { SWITCH_TRACK_COLOR } from '../../constants/colors';
import { getUserSelector } from '../../selectors/login'; import { getUserSelector } from '../../selectors/login';
import RocketChat from '../../lib/rocketchat'; import RocketChat from '../../lib/rocketchat';
const UserPreferencesView = ({ navigation }) => { interface IUserPreferencesViewProps {
navigation: StackNavigationProp<any, 'UserPreferencesView'>;
}
const UserPreferencesView = ({ navigation }: IUserPreferencesViewProps): JSX.Element => {
const user = useSelector(state => getUserSelector(state)); const user = useSelector(state => getUserSelector(state));
const [enableParser, setEnableParser] = useState(user.enableMessageParserEarlyAdoption); const [enableParser, setEnableParser] = useState(user.enableMessageParserEarlyAdoption);
@ -22,12 +26,12 @@ const UserPreferencesView = ({ navigation }) => {
}); });
}, []); }, []);
const navigateToScreen = (screen, params) => { const navigateToScreen = (screen: string) => {
logEvent(events[`SE_GO_${screen.replace('View', '').toUpperCase()}`]); logEvent(events.UP_GO_USER_NOTIFICATION_PREF);
navigation.navigate(screen, params); navigation.navigate(screen);
}; };
const toggleMessageParser = async value => { const toggleMessageParser = async (value: boolean) => {
try { try {
await RocketChat.saveUserPreferences({ id: user.id, enableMessageParserEarlyAdoption: value }); await RocketChat.saveUserPreferences({ id: user.id, enableMessageParserEarlyAdoption: value });
setEnableParser(value); setEnableParser(value);
@ -68,8 +72,4 @@ const UserPreferencesView = ({ navigation }) => {
); );
}; };
UserPreferencesView.propTypes = {
navigation: PropTypes.object
};
export default UserPreferencesView; export default UserPreferencesView;