Skip to content
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

Fix tooltip for mentions #23310

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {TNodeChildrenRenderer} from 'react-native-render-html';
import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';
import Text from '../../Text';
import Tooltip from '../../Tooltip';
import UserDetailsTooltip from '../../UserDetailsTooltip';
import htmlRendererPropTypes from './htmlRendererPropTypes';
import withCurrentUserPersonalDetails from '../../withCurrentUserPersonalDetails';
import personalDetailsPropType from '../../../pages/personalDetailsPropType';
import * as StyleUtils from '../../../styles/StyleUtils';
import * as PersonalDetailsUtils from '../../../libs/PersonalDetailsUtils';
import TextLink from '../../TextLink';

const propTypes = {
Expand All @@ -33,11 +34,18 @@ function MentionUserRenderer(props) {
// We need to remove the leading @ from data as it is not part of the login
const loginWithoutLeadingAt = props.tnode.data.slice(1);

const accountID = _.first(PersonalDetailsUtils.getAccountIDsByLogins([loginWithoutLeadingAt]));

const isOurMention = loginWithoutLeadingAt === props.currentUserPersonalDetails.login;

return (
<Text>
<Tooltip text={loginWithoutLeadingAt}>
<UserDetailsTooltip
accountID={accountID}
fallbackUserDetails={{
displayName: loginWithoutLeadingAt,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to pass anything else here since login is not shown if displayName is same as login

const subtitle = (userLogin || '').trim() && !_.isEqual(LocalePhoneNumber.formatPhoneNumber(userLogin || ''), userDisplayName) ? Str.removeSMSDomain(userLogin) : '';

and avatar is generated from optimistic accountID passed above in UserDetailsTooltip component here -

source={props.icon ? props.icon.source : UserUtils.getAvatar(userAvatar, userAccountID)}

}}
>
<TextLink
// eslint-disable-next-line react/jsx-props-no-spreading
{...defaultRendererProps}
Expand All @@ -49,7 +57,7 @@ function MentionUserRenderer(props) {
>
<TNodeChildrenRenderer tnode={props.tnode} />
</TextLink>
</Tooltip>
</UserDetailsTooltip>
</Text>
);
}
Expand Down