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:
parent
0600c091d3
commit
a6e87c1236
|
@ -155,6 +155,9 @@ export default {
|
|||
SE_CLEAR_LOCAL_SERVER_CACHE: 'se_clear_local_server_cache',
|
||||
SE_LOG_OUT: 'se_log_out',
|
||||
|
||||
// USER PREFERENCE VIEW
|
||||
UP_GO_USER_NOTIFICATION_PREF: 'up_go_user_notification_pref',
|
||||
|
||||
// SECURITY PRIVACY VIEW
|
||||
SP_GO_E2EENCRYPTIONSECURITY: 'sp_go_e2e_encryption_security',
|
||||
SP_GO_SCREENLOCKCONFIG: 'sp_go_screen_lock_cfg',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { StackNavigationProp } from '@react-navigation/stack';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Switch } from 'react-native';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import I18n from '../../i18n';
|
||||
|
@ -12,7 +12,11 @@ import { SWITCH_TRACK_COLOR } from '../../constants/colors';
|
|||
import { getUserSelector } from '../../selectors/login';
|
||||
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 [enableParser, setEnableParser] = useState(user.enableMessageParserEarlyAdoption);
|
||||
|
||||
|
@ -22,12 +26,12 @@ const UserPreferencesView = ({ navigation }) => {
|
|||
});
|
||||
}, []);
|
||||
|
||||
const navigateToScreen = (screen, params) => {
|
||||
logEvent(events[`SE_GO_${screen.replace('View', '').toUpperCase()}`]);
|
||||
navigation.navigate(screen, params);
|
||||
const navigateToScreen = (screen: string) => {
|
||||
logEvent(events.UP_GO_USER_NOTIFICATION_PREF);
|
||||
navigation.navigate(screen);
|
||||
};
|
||||
|
||||
const toggleMessageParser = async value => {
|
||||
const toggleMessageParser = async (value: boolean) => {
|
||||
try {
|
||||
await RocketChat.saveUserPreferences({ id: user.id, enableMessageParserEarlyAdoption: value });
|
||||
setEnableParser(value);
|
||||
|
@ -68,8 +72,4 @@ const UserPreferencesView = ({ navigation }) => {
|
|||
);
|
||||
};
|
||||
|
||||
UserPreferencesView.propTypes = {
|
||||
navigation: PropTypes.object
|
||||
};
|
||||
|
||||
export default UserPreferencesView;
|
Loading…
Reference in New Issue