From a6e87c1236d8cc8b2c5ac665f9a8d526e7a2bd6a Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 10 Nov 2021 15:43:35 -0300 Subject: [PATCH] Chore: Migrate UserPreserencesView to Typescript * chore: migrate the view UserPrederencesView to ts Co-authored-by: Natilorens * minor tweak Co-authored-by: FranciscoHeronildo Co-authored-by: Natilorens Co-authored-by: AlexAlexandre --- app/utils/log/events.js | 3 +++ .../{index.js => index.tsx} | 20 +++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) rename app/views/UserPreferencesView/{index.js => index.tsx} (80%) diff --git a/app/utils/log/events.js b/app/utils/log/events.js index 505a42e4c..fc7a3497a 100644 --- a/app/utils/log/events.js +++ b/app/utils/log/events.js @@ -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', diff --git a/app/views/UserPreferencesView/index.js b/app/views/UserPreferencesView/index.tsx similarity index 80% rename from app/views/UserPreferencesView/index.js rename to app/views/UserPreferencesView/index.tsx index 476c49a7d..2abce444e 100644 --- a/app/views/UserPreferencesView/index.js +++ b/app/views/UserPreferencesView/index.tsx @@ -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; +} + +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;