Display surname for contacts without first name (#1015)
This commit is contained in:
parent
ba62d35c42
commit
41cb364b40
@ -7,7 +7,7 @@ import { GlobalActions } from '../../global/types';
|
|||||||
import { selectIsChatWithSelf, selectUser } from '../../modules/selectors';
|
import { selectIsChatWithSelf, selectUser } from '../../modules/selectors';
|
||||||
import {
|
import {
|
||||||
isChatPrivate,
|
isChatPrivate,
|
||||||
getUserFirstName,
|
getUserFirstOrLastName,
|
||||||
getPrivateChatUserId,
|
getPrivateChatUserId,
|
||||||
isChatBasicGroup,
|
isChatBasicGroup,
|
||||||
isChatSuperGroup,
|
isChatSuperGroup,
|
||||||
@ -37,7 +37,7 @@ type StateProps = {
|
|||||||
isSuperGroup: boolean;
|
isSuperGroup: boolean;
|
||||||
canDeleteForAll?: boolean;
|
canDeleteForAll?: boolean;
|
||||||
chatTitle: string;
|
chatTitle: string;
|
||||||
contactFirstName?: string;
|
contactName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DispatchProps = Pick<GlobalActions, 'leaveChannel' | 'deleteHistory' | 'deleteChannel'>;
|
type DispatchProps = Pick<GlobalActions, 'leaveChannel' | 'deleteHistory' | 'deleteChannel'>;
|
||||||
@ -52,7 +52,7 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
isSuperGroup,
|
isSuperGroup,
|
||||||
canDeleteForAll,
|
canDeleteForAll,
|
||||||
chatTitle,
|
chatTitle,
|
||||||
contactFirstName,
|
contactName,
|
||||||
onClose,
|
onClose,
|
||||||
leaveChannel,
|
leaveChannel,
|
||||||
deleteHistory,
|
deleteHistory,
|
||||||
@ -129,7 +129,7 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
return <p>Are you sure you want to leave group <strong>{chatTitle}</strong>?</p>;
|
return <p>Are you sure you want to leave group <strong>{chatTitle}</strong>?</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <p>Are you sure you want to delete chat with <strong>{contactFirstName}</strong>?</p>;
|
return <p>Are you sure you want to delete chat with <strong>{contactName}</strong>?</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderActionText() {
|
function renderActionText() {
|
||||||
@ -157,7 +157,7 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
{renderMessage()}
|
{renderMessage()}
|
||||||
{canDeleteForAll && (
|
{canDeleteForAll && (
|
||||||
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForAll}>
|
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForAll}>
|
||||||
Delete for {contactFirstName ? `me and ${contactFirstName}` : 'Everyone'}
|
Delete for {contactName ? `me and ${contactName}` : 'Everyone'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteChat}>
|
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteChat}>
|
||||||
@ -173,8 +173,8 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const isPrivateChat = isChatPrivate(chat.id);
|
const isPrivateChat = isChatPrivate(chat.id);
|
||||||
const isChatWithSelf = selectIsChatWithSelf(global, chat.id);
|
const isChatWithSelf = selectIsChatWithSelf(global, chat.id);
|
||||||
const canDeleteForAll = (isPrivateChat && !isChatWithSelf);
|
const canDeleteForAll = (isPrivateChat && !isChatWithSelf);
|
||||||
const contactFirstName = chat && isChatPrivate(chat.id)
|
const contactName = chat && isChatPrivate(chat.id)
|
||||||
? getUserFirstName(selectUser(global, getPrivateChatUserId(chat)!))
|
? getUserFirstOrLastName(selectUser(global, getPrivateChatUserId(chat)!))
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -185,7 +185,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
isSuperGroup: isChatSuperGroup(chat),
|
isSuperGroup: isChatSuperGroup(chat),
|
||||||
canDeleteForAll,
|
canDeleteForAll,
|
||||||
chatTitle: getChatTitle(chat),
|
chatTitle: getChatTitle(chat),
|
||||||
contactFirstName,
|
contactName,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions, ['leaveChannel', 'deleteHistory', 'deleteChannel']),
|
(setGlobal, actions): DispatchProps => pick(actions, ['leaveChannel', 'deleteHistory', 'deleteChannel']),
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import {
|
|||||||
} from '../../modules/selectors';
|
} from '../../modules/selectors';
|
||||||
import {
|
import {
|
||||||
isChatPrivate,
|
isChatPrivate,
|
||||||
getUserFirstName,
|
getUserFirstOrLastName,
|
||||||
getPrivateChatUserId,
|
getPrivateChatUserId,
|
||||||
isChatBasicGroup,
|
isChatBasicGroup,
|
||||||
isChatSuperGroup,
|
isChatSuperGroup,
|
||||||
@ -36,7 +36,7 @@ export type OwnProps = {
|
|||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
canDeleteForAll?: boolean;
|
canDeleteForAll?: boolean;
|
||||||
contactFirstName?: string;
|
contactName?: string;
|
||||||
willDeleteForCurrentUserOnly?: boolean;
|
willDeleteForCurrentUserOnly?: boolean;
|
||||||
willDeleteForAll?: boolean;
|
willDeleteForAll?: boolean;
|
||||||
};
|
};
|
||||||
@ -49,7 +49,7 @@ const DeleteMessageModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
message,
|
message,
|
||||||
album,
|
album,
|
||||||
canDeleteForAll,
|
canDeleteForAll,
|
||||||
contactFirstName,
|
contactName,
|
||||||
willDeleteForCurrentUserOnly,
|
willDeleteForCurrentUserOnly,
|
||||||
willDeleteForAll,
|
willDeleteForAll,
|
||||||
onClose,
|
onClose,
|
||||||
@ -98,8 +98,8 @@ const DeleteMessageModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
)}
|
)}
|
||||||
{canDeleteForAll && (
|
{canDeleteForAll && (
|
||||||
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForAll}>
|
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForAll}>
|
||||||
Delete for {contactFirstName ? 'me and ' : 'Everyone'}
|
Delete for {contactName ? 'me and ' : 'Everyone'}
|
||||||
{contactFirstName && renderText(contactFirstName)}
|
{contactName && renderText(contactName)}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForSelf}>
|
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForSelf}>
|
||||||
@ -115,8 +115,8 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const { threadId } = selectCurrentMessageList(global) || {};
|
const { threadId } = selectCurrentMessageList(global) || {};
|
||||||
const { canDeleteForAll } = (threadId && selectAllowedMessageActions(global, message, threadId)) || {};
|
const { canDeleteForAll } = (threadId && selectAllowedMessageActions(global, message, threadId)) || {};
|
||||||
const chat = selectChat(global, message.chatId);
|
const chat = selectChat(global, message.chatId);
|
||||||
const contactFirstName = chat && isChatPrivate(chat.id)
|
const contactName = chat && isChatPrivate(chat.id)
|
||||||
? getUserFirstName(selectUser(global, getPrivateChatUserId(chat)!))
|
? getUserFirstOrLastName(selectUser(global, getPrivateChatUserId(chat)!))
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const willDeleteForCurrentUserOnly = chat && isChatBasicGroup(chat) && !canDeleteForAll;
|
const willDeleteForCurrentUserOnly = chat && isChatBasicGroup(chat) && !canDeleteForAll;
|
||||||
@ -124,7 +124,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
canDeleteForAll: !isSchedule && canDeleteForAll,
|
canDeleteForAll: !isSchedule && canDeleteForAll,
|
||||||
contactFirstName,
|
contactName,
|
||||||
willDeleteForCurrentUserOnly,
|
willDeleteForCurrentUserOnly,
|
||||||
willDeleteForAll,
|
willDeleteForAll,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { withGlobal } from '../../lib/teact/teactn';
|
|||||||
import { ApiChat, ApiUser } from '../../api/types';
|
import { ApiChat, ApiUser } from '../../api/types';
|
||||||
|
|
||||||
import { selectChat, selectUser } from '../../modules/selectors';
|
import { selectChat, selectUser } from '../../modules/selectors';
|
||||||
import { getChatTitle, getUserFirstName, isChatPrivate } from '../../modules/helpers';
|
import { getChatTitle, getUserFirstOrLastName, isChatPrivate } from '../../modules/helpers';
|
||||||
import renderText from './helpers/renderText';
|
import renderText from './helpers/renderText';
|
||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
import useLang from '../../hooks/useLang';
|
import useLang from '../../hooks/useLang';
|
||||||
@ -64,7 +64,7 @@ const PickerSelectedItem: FC<OwnProps & StateProps> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const name = !chat || (user && !user.isSelf)
|
const name = !chat || (user && !user.isSelf)
|
||||||
? getUserFirstName(user)
|
? getUserFirstOrLastName(user)
|
||||||
: getChatTitle(chat, user);
|
: getChatTitle(chat, user);
|
||||||
|
|
||||||
titleText = name ? renderText(name) : undefined;
|
titleText = name ? renderText(name) : undefined;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { GlobalActions } from '../../global/types';
|
|||||||
import { selectChat, selectIsChatWithSelf, selectUser } from '../../modules/selectors';
|
import { selectChat, selectIsChatWithSelf, selectUser } from '../../modules/selectors';
|
||||||
import {
|
import {
|
||||||
isChatPrivate,
|
isChatPrivate,
|
||||||
getUserFirstName,
|
getUserFirstOrLastName,
|
||||||
getPrivateChatUserId,
|
getPrivateChatUserId,
|
||||||
isChatBasicGroup,
|
isChatBasicGroup,
|
||||||
isChatSuperGroup,
|
isChatSuperGroup,
|
||||||
@ -32,7 +32,7 @@ type StateProps = {
|
|||||||
isGroup: boolean;
|
isGroup: boolean;
|
||||||
isSuperGroup: boolean;
|
isSuperGroup: boolean;
|
||||||
canPinForAll: boolean;
|
canPinForAll: boolean;
|
||||||
contactFirstName?: string;
|
contactName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DispatchProps = Pick<GlobalActions, 'pinMessage'>;
|
type DispatchProps = Pick<GlobalActions, 'pinMessage'>;
|
||||||
@ -45,7 +45,7 @@ const PinMessageModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
isGroup,
|
isGroup,
|
||||||
isSuperGroup,
|
isSuperGroup,
|
||||||
canPinForAll,
|
canPinForAll,
|
||||||
contactFirstName,
|
contactName,
|
||||||
onClose,
|
onClose,
|
||||||
pinMessage,
|
pinMessage,
|
||||||
}) => {
|
}) => {
|
||||||
@ -98,7 +98,7 @@ const PinMessageModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
</Button>
|
</Button>
|
||||||
{canPinForAll && (
|
{canPinForAll && (
|
||||||
<Button className="confirm-dialog-button" isText onClick={handlePinMessageForAll}>
|
<Button className="confirm-dialog-button" isText onClick={handlePinMessageForAll}>
|
||||||
{contactFirstName ? `Pin for me and ${contactFirstName}` : 'Pin and notify all memebers'}
|
{contactName ? `Pin for me and ${contactName}` : 'Pin and notify all memebers'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button className="confirm-dialog-button" isText onClick={onClose}>{lang('Cancel')}</Button>
|
<Button className="confirm-dialog-button" isText onClick={onClose}>{lang('Cancel')}</Button>
|
||||||
@ -115,8 +115,8 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const isGroup = !!chat && isChatBasicGroup(chat);
|
const isGroup = !!chat && isChatBasicGroup(chat);
|
||||||
const isSuperGroup = !!chat && isChatSuperGroup(chat);
|
const isSuperGroup = !!chat && isChatSuperGroup(chat);
|
||||||
const canPinForAll = (isPrivateChat && !isChatWithSelf) || isSuperGroup || isGroup;
|
const canPinForAll = (isPrivateChat && !isChatWithSelf) || isSuperGroup || isGroup;
|
||||||
const contactFirstName = chat && isChatPrivate(chat.id)
|
const contactName = chat && isChatPrivate(chat.id)
|
||||||
? getUserFirstName(selectUser(global, getPrivateChatUserId(chat)!))
|
? getUserFirstOrLastName(selectUser(global, getPrivateChatUserId(chat)!))
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -126,7 +126,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
isGroup,
|
isGroup,
|
||||||
isSuperGroup,
|
isSuperGroup,
|
||||||
canPinForAll,
|
canPinForAll,
|
||||||
contactFirstName,
|
contactName,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions, ['pinMessage']),
|
(setGlobal, actions): DispatchProps => pick(actions, ['pinMessage']),
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { withGlobal } from '../../lib/teact/teactn';
|
|||||||
import { ApiUser, ApiTypingStatus } from '../../api/types';
|
import { ApiUser, ApiTypingStatus } from '../../api/types';
|
||||||
|
|
||||||
import { selectUser } from '../../modules/selectors';
|
import { selectUser } from '../../modules/selectors';
|
||||||
import { getUserFirstName } from '../../modules/helpers';
|
import { getUserFirstOrLastName } from '../../modules/helpers';
|
||||||
import renderText from './helpers/renderText';
|
import renderText from './helpers/renderText';
|
||||||
|
|
||||||
import './TypingStatus.scss';
|
import './TypingStatus.scss';
|
||||||
@ -18,7 +18,7 @@ type StateProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const TypingStatus: FC<OwnProps & StateProps> = ({ typingStatus, typingUser }) => {
|
const TypingStatus: FC<OwnProps & StateProps> = ({ typingStatus, typingUser }) => {
|
||||||
const typingUserName = typingUser && !typingUser.isSelf && getUserFirstName(typingUser);
|
const typingUserName = typingUser && !typingUser.isSelf && getUserFirstOrLastName(typingUser);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p className="typing-status">
|
<p className="typing-status">
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { withGlobal } from '../../../lib/teact/teactn';
|
|||||||
import { GlobalActions } from '../../../global/types';
|
import { GlobalActions } from '../../../global/types';
|
||||||
import { ApiUser } from '../../../api/types';
|
import { ApiUser } from '../../../api/types';
|
||||||
|
|
||||||
import { getUserFirstName } from '../../../modules/helpers';
|
import { getUserFirstOrLastName } from '../../../modules/helpers';
|
||||||
import renderText from '../../common/helpers/renderText';
|
import renderText from '../../common/helpers/renderText';
|
||||||
import { throttle } from '../../../util/schedulers';
|
import { throttle } from '../../../util/schedulers';
|
||||||
import { pick } from '../../../util/iteratees';
|
import { pick } from '../../../util/iteratees';
|
||||||
@ -79,7 +79,7 @@ const RecentContacts: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
{topUserIds.map((userId) => (
|
{topUserIds.map((userId) => (
|
||||||
<div className="top-peer-item" onClick={() => handleClick(userId)}>
|
<div className="top-peer-item" onClick={() => handleClick(userId)}>
|
||||||
<Avatar user={usersById[userId]} />
|
<Avatar user={usersById[userId]} />
|
||||||
<div className="top-peer-name">{renderText(getUserFirstName(usersById[userId]) || NBSP)}</div>
|
<div className="top-peer-name">{renderText(getUserFirstOrLastName(usersById[userId]) || NBSP)}</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { GlobalActions } from '../../global/types';
|
|||||||
import { selectCanDeleteSelectedMessages, selectCurrentChat, selectUser } from '../../modules/selectors';
|
import { selectCanDeleteSelectedMessages, selectCurrentChat, selectUser } from '../../modules/selectors';
|
||||||
import {
|
import {
|
||||||
isChatPrivate,
|
isChatPrivate,
|
||||||
getUserFirstName,
|
getUserFirstOrLastName,
|
||||||
getPrivateChatUserId,
|
getPrivateChatUserId,
|
||||||
isChatBasicGroup,
|
isChatBasicGroup,
|
||||||
isChatSuperGroup,
|
isChatSuperGroup,
|
||||||
@ -27,7 +27,7 @@ export type OwnProps = {
|
|||||||
type StateProps = {
|
type StateProps = {
|
||||||
selectedMessageIds?: number[];
|
selectedMessageIds?: number[];
|
||||||
canDeleteForAll?: boolean;
|
canDeleteForAll?: boolean;
|
||||||
contactFirstName?: string;
|
contactName?: string;
|
||||||
willDeleteForCurrentUserOnly?: boolean;
|
willDeleteForCurrentUserOnly?: boolean;
|
||||||
willDeleteForAll?: boolean;
|
willDeleteForAll?: boolean;
|
||||||
};
|
};
|
||||||
@ -39,7 +39,7 @@ const DeleteSelectedMessagesModal: FC<OwnProps & StateProps & DispatchProps> = (
|
|||||||
isSchedule,
|
isSchedule,
|
||||||
selectedMessageIds,
|
selectedMessageIds,
|
||||||
canDeleteForAll,
|
canDeleteForAll,
|
||||||
contactFirstName,
|
contactName,
|
||||||
willDeleteForCurrentUserOnly,
|
willDeleteForCurrentUserOnly,
|
||||||
willDeleteForAll,
|
willDeleteForAll,
|
||||||
onClose,
|
onClose,
|
||||||
@ -89,8 +89,8 @@ const DeleteSelectedMessagesModal: FC<OwnProps & StateProps & DispatchProps> = (
|
|||||||
)}
|
)}
|
||||||
{canDeleteForAll && (
|
{canDeleteForAll && (
|
||||||
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForAll}>
|
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForAll}>
|
||||||
Delete for {contactFirstName ? 'me and ' : 'Everyone'}
|
Delete for {contactName ? 'me and ' : 'Everyone'}
|
||||||
{contactFirstName && renderText(contactFirstName)}
|
{contactName && renderText(contactName)}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForSelf}>
|
<Button color="danger" className="confirm-dialog-button" isText onClick={handleDeleteMessageForSelf}>
|
||||||
@ -106,8 +106,8 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const { messageIds: selectedMessageIds } = global.selectedMessages || {};
|
const { messageIds: selectedMessageIds } = global.selectedMessages || {};
|
||||||
const { canDeleteForAll } = selectCanDeleteSelectedMessages(global);
|
const { canDeleteForAll } = selectCanDeleteSelectedMessages(global);
|
||||||
const chat = selectCurrentChat(global);
|
const chat = selectCurrentChat(global);
|
||||||
const contactFirstName = chat && isChatPrivate(chat.id)
|
const contactName = chat && isChatPrivate(chat.id)
|
||||||
? getUserFirstName(selectUser(global, getPrivateChatUserId(chat)!))
|
? getUserFirstOrLastName(selectUser(global, getPrivateChatUserId(chat)!))
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const willDeleteForCurrentUserOnly = chat && isChatBasicGroup(chat) && !canDeleteForAll;
|
const willDeleteForCurrentUserOnly = chat && isChatBasicGroup(chat) && !canDeleteForAll;
|
||||||
@ -116,7 +116,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
return {
|
return {
|
||||||
selectedMessageIds,
|
selectedMessageIds,
|
||||||
canDeleteForAll: !isSchedule && canDeleteForAll,
|
canDeleteForAll: !isSchedule && canDeleteForAll,
|
||||||
contactFirstName,
|
contactName,
|
||||||
willDeleteForCurrentUserOnly,
|
willDeleteForCurrentUserOnly,
|
||||||
willDeleteForAll,
|
willDeleteForAll,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from '../../../../lib/teact/teact';
|
|||||||
|
|
||||||
import { ApiMessageEntityTypes, ApiChatMember, ApiUser } from '../../../../api/types';
|
import { ApiMessageEntityTypes, ApiChatMember, ApiUser } from '../../../../api/types';
|
||||||
import { EDITABLE_INPUT_ID } from '../../../../config';
|
import { EDITABLE_INPUT_ID } from '../../../../config';
|
||||||
import { getUserFirstName } from '../../../../modules/helpers';
|
import { getUserFirstOrLastName } from '../../../../modules/helpers';
|
||||||
import searchUserName from '../helpers/searchUserName';
|
import searchUserName from '../helpers/searchUserName';
|
||||||
import { IS_MOBILE_SCREEN } from '../../../../util/environment';
|
import { IS_MOBILE_SCREEN } from '../../../../util/environment';
|
||||||
import focusEditableElement from '../../../../util/focusEditableElement';
|
import focusEditableElement from '../../../../util/focusEditableElement';
|
||||||
@ -62,7 +62,7 @@ export default function useMentionMenu(
|
|||||||
}, [canSuggestMembers, html, getFilteredMembers, markIsOpen, unmarkIsOpen]);
|
}, [canSuggestMembers, html, getFilteredMembers, markIsOpen, unmarkIsOpen]);
|
||||||
|
|
||||||
const insertMention = useCallback((user: ApiUser, forceFocus = false) => {
|
const insertMention = useCallback((user: ApiUser, forceFocus = false) => {
|
||||||
if (!user.username && !getUserFirstName(user)) {
|
if (!user.username && !getUserFirstOrLastName(user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ export default function useMentionMenu(
|
|||||||
data-entity-type="${ApiMessageEntityTypes.MentionName}"
|
data-entity-type="${ApiMessageEntityTypes.MentionName}"
|
||||||
data-user-id="${user.id}"
|
data-user-id="${user.id}"
|
||||||
contenteditable="false"
|
contenteditable="false"
|
||||||
>${getUserFirstName(user)}</a>`;
|
>${getUserFirstOrLastName(user)}</a>`;
|
||||||
|
|
||||||
const atIndex = html.lastIndexOf('@');
|
const atIndex = html.lastIndexOf('@');
|
||||||
if (atIndex !== -1) {
|
if (atIndex !== -1) {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import {
|
|||||||
|
|
||||||
import { ARCHIVED_FOLDER_ID } from '../../config';
|
import { ARCHIVED_FOLDER_ID } from '../../config';
|
||||||
import { orderBy } from '../../util/iteratees';
|
import { orderBy } from '../../util/iteratees';
|
||||||
import { getUserFirstName } from './users';
|
import { getUserFirstOrLastName } from './users';
|
||||||
import { getTranslation } from '../../util/langProvider';
|
import { getTranslation } from '../../util/langProvider';
|
||||||
import { LangFn } from '../../hooks/useLang';
|
import { LangFn } from '../../hooks/useLang';
|
||||||
|
|
||||||
@ -430,5 +430,5 @@ export function getMessageSenderName(chatId: number, sender?: ApiUser) {
|
|||||||
return 'You';
|
return 'You';
|
||||||
}
|
}
|
||||||
|
|
||||||
return getUserFirstName(sender);
|
return getUserFirstOrLastName(sender);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { LangFn } from '../../hooks/useLang';
|
|||||||
|
|
||||||
const USER_COLOR_KEYS = [1, 8, 5, 2, 7, 4, 6];
|
const USER_COLOR_KEYS = [1, 8, 5, 2, 7, 4, 6];
|
||||||
|
|
||||||
export function getUserFirstName(user?: ApiUser) {
|
export function getUserFirstOrLastName(user?: ApiUser) {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ export function getUserFirstName(user?: ApiUser) {
|
|||||||
switch (user.type) {
|
switch (user.type) {
|
||||||
case 'userTypeBot':
|
case 'userTypeBot':
|
||||||
case 'userTypeRegular': {
|
case 'userTypeRegular': {
|
||||||
return user.firstName;
|
return user.firstName || user.lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'userTypeDeleted':
|
case 'userTypeDeleted':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user