-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Drop domain name in mentions if chat members are on the same domain #34013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
5dbf2c9
e9899c4
c3958df
7bf4ad6
a6f9f74
2d7dcd8
099a7cc
8f68bc3
a3e4109
f709b32
0273d3c
47359b7
2c7cf2b
bb27914
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import {cloneDeep} from 'lodash'; | ||
import lodashGet from 'lodash/get'; | ||
import React from 'react'; | ||
import {TNodeChildrenRenderer} from 'react-native-render-html'; | ||
|
@@ -16,6 +17,7 @@ import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; | |
import * as ReportUtils from '@libs/ReportUtils'; | ||
import personalDetailsPropType from '@pages/personalDetailsPropType'; | ||
import CONST from '@src/CONST'; | ||
import * as LoginUtils from '@src/libs/LoginUtils'; | ||
import ROUTES from '@src/ROUTES'; | ||
import htmlRendererPropTypes from './htmlRendererPropTypes'; | ||
|
||
|
@@ -37,15 +39,28 @@ function MentionUserRenderer(props) { | |
let accountID; | ||
let displayNameOrLogin; | ||
let navigationRoute; | ||
const tnode = cloneDeep(props.tnode); | ||
const getMentionDisplayText = (displayText, accountId, userLogin = '') => { | ||
if (accountId && userLogin !== displayText) { | ||
return displayText; | ||
} | ||
if (!LoginUtils.areEmailsFromSamePrivateDomain(displayText, props.currentUserPersonalDetails.login)) { | ||
return displayText; | ||
} | ||
tienifr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return displayText.split('@')[0]; | ||
}; | ||
|
||
if (!_.isEmpty(htmlAttribAccountID)) { | ||
const user = lodashGet(personalDetails, htmlAttribAccountID); | ||
accountID = parseInt(htmlAttribAccountID, 10); | ||
displayNameOrLogin = LocalePhoneNumber.formatPhoneNumber(lodashGet(user, 'login', '')) || lodashGet(user, 'displayName', '') || translate('common.hidden'); | ||
displayNameOrLogin = getMentionDisplayText(displayNameOrLogin, htmlAttribAccountID, lodashGet(user, 'login', '')); | ||
navigationRoute = ROUTES.PROFILE.getRoute(htmlAttribAccountID); | ||
} else if (!_.isEmpty(props.tnode.data)) { | ||
} else if (!_.isEmpty(tnode.data)) { | ||
// We need to remove the LTR unicode and leading @ from data as it is not part of the login | ||
displayNameOrLogin = props.tnode.data.replace(CONST.UNICODE.LTR, '').slice(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change will probably cause issue. We are passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing that out. I updated the PR |
||
displayNameOrLogin = tnode.data.replace(CONST.UNICODE.LTR, '').slice(1); | ||
tnode.data = tnode.data.replace(displayNameOrLogin, getMentionDisplayText(displayNameOrLogin, htmlAttribAccountID)); | ||
tienifr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
accountID = _.first(PersonalDetailsUtils.getAccountIDsByLogins([displayNameOrLogin])); | ||
navigationRoute = ROUTES.DETAILS.getRoute(displayNameOrLogin); | ||
|
@@ -83,7 +98,7 @@ function MentionUserRenderer(props) { | |
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...defaultRendererProps} | ||
> | ||
{!_.isEmpty(htmlAttribAccountID) ? `@${displayNameOrLogin}` : <TNodeChildrenRenderer tnode={props.tnode} />} | ||
{!_.isEmpty(htmlAttribAccountID) ? `@${displayNameOrLogin}` : <TNodeChildrenRenderer tnode={tnode} />} | ||
</Text> | ||
</UserDetailsTooltip> | ||
</Text> | ||
|
Uh oh!
There was an error while loading. Please reload this page.