Skip to content

Commit

Permalink
Merge pull request #23772 from hungvu193/fix-23113
Browse files Browse the repository at this point in the history
fix redundant api call on priority page
  • Loading branch information
cristipaval authored Jul 31, 2023
2 parents 1fa4b72 + fc4b4aa commit b041a2c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/pages/settings/Preferences/PriorityModePage.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<HeaderWithBackButton
Expand All @@ -46,7 +57,7 @@ function PriorityModePage(props) {
<Text style={[styles.mh5, styles.mv4]}>{props.translate('priorityModePage.explainerText')}</Text>
<SelectionListRadio
sections={[{data: priorityModes}]}
onSelectRow={(mode) => User.updateChatPriorityMode(mode.value)}
onSelectRow={updateMode}
initiallyFocusedOptionKey={_.find(priorityModes, (mode) => mode.isSelected).keyForList}
/>
</ScreenWrapper>
Expand Down

0 comments on commit b041a2c

Please sign in to comment.