Profile: Channel link should be displayed instead of username (#1272)

This commit is contained in:
Alexander Zinchuk 2021-07-14 19:57:50 +03:00
parent b3f9fc0f12
commit 4d97ac396e
2 changed files with 7 additions and 12 deletions

View File

@ -54,10 +54,7 @@ const ChatExtra: FC<OwnProps & StateProps & DispatchProps> = ({
phoneNumber, phoneNumber,
isSelf, isSelf,
} = user || {}; } = user || {};
const { const { id: chatId } = chat || {};
id: chatId,
username: chatUsername,
} = chat || {};
const lang = useLang(); const lang = useLang();
useEffect(() => { useEffect(() => {
@ -81,8 +78,6 @@ const ChatExtra: FC<OwnProps & StateProps & DispatchProps> = ({
const formattedNumber = phoneNumber && formatPhoneNumberWithCode(phoneNumber); const formattedNumber = phoneNumber && formatPhoneNumberWithCode(phoneNumber);
const link = getChatLink(chat); const link = getChatLink(chat);
const url = link.indexOf('http') === 0 ? link : `http://${link}`;
const printedUsername = username || chatUsername;
const description = (fullInfo && fullInfo.bio) || getChatDescription(chat); const description = (fullInfo && fullInfo.bio) || getChatDescription(chat);
return ( return (
@ -93,15 +88,15 @@ const ChatExtra: FC<OwnProps & StateProps & DispatchProps> = ({
<span className="subtitle">{lang('Phone')}</span> <span className="subtitle">{lang('Phone')}</span>
</ListItem> </ListItem>
)} )}
{printedUsername && ( {username && (
<ListItem <ListItem
icon="mention" icon="mention"
multiline multiline
narrow narrow
ripple ripple
onClick={() => copy(`@${printedUsername}`, lang('Username'))} onClick={() => copy(`@${username}`, lang('Username'))}
> >
<span className="title" dir="auto">{renderText(printedUsername)}</span> <span className="title" dir="auto">{renderText(username)}</span>
<span className="subtitle">{lang('Username')}</span> <span className="subtitle">{lang('Username')}</span>
</ListItem> </ListItem>
)} )}
@ -118,10 +113,10 @@ const ChatExtra: FC<OwnProps & StateProps & DispatchProps> = ({
<span className="subtitle">{lang(userId ? 'UserBio' : 'Info')}</span> <span className="subtitle">{lang(userId ? 'UserBio' : 'Info')}</span>
</ListItem> </ListItem>
)} )}
{canInviteUsers && !printedUsername && !!link.length && ( {(canInviteUsers || !username) && !!link.length && (
<ListItem icon="mention" multiline narrow ripple onClick={() => copy(link, lang('SetUrlPlaceholder'))}> <ListItem icon="mention" multiline narrow ripple onClick={() => copy(link, lang('SetUrlPlaceholder'))}>
<div className="title"> <div className="title">
<SafeLink url={url} className="title" text={link} /> <SafeLink url={link} className="title" text={link} />
</div> </div>
<span className="subtitle">{lang('SetUrlPlaceholder')}</span> <span className="subtitle">{lang('SetUrlPlaceholder')}</span>
</ListItem> </ListItem>

View File

@ -84,7 +84,7 @@ export function getChatLink(chat: ApiChat) {
return inviteLink; return inviteLink;
} }
return username ? `t.me/${username}` : ''; return username ? `https://t.me/${username}` : '';
} }
export function getChatAvatarHash( export function getChatAvatarHash(