From fc4b4aa5a6fa610fdc74812958a46d88d1ec87fd Mon Sep 17 00:00:00 2001 From: Hans Date: Fri, 28 Jul 2023 06:56:26 +0700 Subject: [PATCH] fix rudundant api call on priority page --- .../settings/Preferences/PriorityModePage.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Preferences/PriorityModePage.js b/src/pages/settings/Preferences/PriorityModePage.js index 3c3ea5bfe6f8..8c3a74cf5d46 100644 --- a/src/pages/settings/Preferences/PriorityModePage.js +++ b/src/pages/settings/Preferences/PriorityModePage.js @@ -1,5 +1,5 @@ import _, {compose} from 'underscore'; -import React from 'react'; +import React, {useCallback} from 'react'; import {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; @@ -37,6 +37,17 @@ function PriorityModePage(props) { isSelected: props.priorityMode === key, })); + const updateMode = useCallback( + (mode) => { + if (mode.value === props.priorityMode) { + Navigation.navigate(ROUTES.SETTINGS_PREFERENCES); + return; + } + User.updateChatPriorityMode(mode.value); + }, + [props.priorityMode], + ); + return ( {props.translate('priorityModePage.explainerText')} User.updateChatPriorityMode(mode.value)} + onSelectRow={updateMode} initiallyFocusedOptionKey={_.find(priorityModes, (mode) => mode.isSelected).keyForList} />