Skip to content

Commit

Permalink
Merge pull request #18029 from akinwale/task-17883
Browse files Browse the repository at this point in the history
fix: always show the default contact method at the top of the "Contact methods" list
  • Loading branch information
Beamanator authored Apr 28, 2023
2 parents 1c38cd8 + fe4fa44 commit c3c86d3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pages/settings/Profile/Contacts/ContactMethodsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ const defaultProps = {
};

const ContactMethodsPage = (props) => {
const loginMenuItems = _.map(props.loginList, (login, loginName) => {
const loginNames = _.keys(props.loginList);

// Sort the login names by placing the one corresponding to the default contact method as the first item before displaying the contact methods.
// The default contact method is determined by checking against the session email (the current login).
const sortedLoginNames = _.sortBy(loginNames, loginName => (props.loginList[loginName].partnerUserID === props.session.email ? 0 : 1));

const loginMenuItems = _.map(sortedLoginNames, (loginName) => {
const login = props.loginList[loginName];
const pendingAction = lodashGet(login, 'pendingFields.deletedLogin') || lodashGet(login, 'pendingFields.addedLogin');
if (!login.partnerUserID && _.isEmpty(pendingAction)) {
return null;
Expand Down

0 comments on commit c3c86d3

Please sign in to comment.