From 41cb364b40833daa607873afb480897cb7156654 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 16 Apr 2021 14:48:24 +0300 Subject: [PATCH] Display surname for contacts without first name (#1015) --- src/components/common/DeleteChatModal.tsx | 16 ++++++++-------- src/components/common/DeleteMessageModal.tsx | 16 ++++++++-------- src/components/common/PickerSelectedItem.tsx | 4 ++-- src/components/common/PinMessageModal.tsx | 14 +++++++------- src/components/common/TypingStatus.tsx | 4 ++-- src/components/left/search/RecentContacts.tsx | 4 ++-- .../middle/DeleteSelectedMessagesModal.tsx | 16 ++++++++-------- .../middle/composer/hooks/useMentionMenu.ts | 6 +++--- src/modules/helpers/chats.ts | 4 ++-- src/modules/helpers/users.ts | 4 ++-- 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/components/common/DeleteChatModal.tsx b/src/components/common/DeleteChatModal.tsx index b66bc04b8..6e56abc73 100644 --- a/src/components/common/DeleteChatModal.tsx +++ b/src/components/common/DeleteChatModal.tsx @@ -7,7 +7,7 @@ import { GlobalActions } from '../../global/types'; import { selectIsChatWithSelf, selectUser } from '../../modules/selectors'; import { isChatPrivate, - getUserFirstName, + getUserFirstOrLastName, getPrivateChatUserId, isChatBasicGroup, isChatSuperGroup, @@ -37,7 +37,7 @@ type StateProps = { isSuperGroup: boolean; canDeleteForAll?: boolean; chatTitle: string; - contactFirstName?: string; + contactName?: string; }; type DispatchProps = Pick; @@ -52,7 +52,7 @@ const DeleteChatModal: FC = ({ isSuperGroup, canDeleteForAll, chatTitle, - contactFirstName, + contactName, onClose, leaveChannel, deleteHistory, @@ -129,7 +129,7 @@ const DeleteChatModal: FC = ({ return

Are you sure you want to leave group {chatTitle}?

; } - return

Are you sure you want to delete chat with {contactFirstName}?

; + return

Are you sure you want to delete chat with {contactName}?

; } function renderActionText() { @@ -157,7 +157,7 @@ const DeleteChatModal: FC = ({ {renderMessage()} {canDeleteForAll && ( )} )} {canPinForAll && ( )} @@ -115,8 +115,8 @@ export default memo(withGlobal( const isGroup = !!chat && isChatBasicGroup(chat); const isSuperGroup = !!chat && isChatSuperGroup(chat); const canPinForAll = (isPrivateChat && !isChatWithSelf) || isSuperGroup || isGroup; - const contactFirstName = chat && isChatPrivate(chat.id) - ? getUserFirstName(selectUser(global, getPrivateChatUserId(chat)!)) + const contactName = chat && isChatPrivate(chat.id) + ? getUserFirstOrLastName(selectUser(global, getPrivateChatUserId(chat)!)) : undefined; return { @@ -126,7 +126,7 @@ export default memo(withGlobal( isGroup, isSuperGroup, canPinForAll, - contactFirstName, + contactName, }; }, (setGlobal, actions): DispatchProps => pick(actions, ['pinMessage']), diff --git a/src/components/common/TypingStatus.tsx b/src/components/common/TypingStatus.tsx index c63cc4d9f..a7f99ffcd 100644 --- a/src/components/common/TypingStatus.tsx +++ b/src/components/common/TypingStatus.tsx @@ -4,7 +4,7 @@ import { withGlobal } from '../../lib/teact/teactn'; import { ApiUser, ApiTypingStatus } from '../../api/types'; import { selectUser } from '../../modules/selectors'; -import { getUserFirstName } from '../../modules/helpers'; +import { getUserFirstOrLastName } from '../../modules/helpers'; import renderText from './helpers/renderText'; import './TypingStatus.scss'; @@ -18,7 +18,7 @@ type StateProps = { }; const TypingStatus: FC = ({ typingStatus, typingUser }) => { - const typingUserName = typingUser && !typingUser.isSelf && getUserFirstName(typingUser); + const typingUserName = typingUser && !typingUser.isSelf && getUserFirstOrLastName(typingUser); return (

diff --git a/src/components/left/search/RecentContacts.tsx b/src/components/left/search/RecentContacts.tsx index c362e7522..6cfc4bd68 100644 --- a/src/components/left/search/RecentContacts.tsx +++ b/src/components/left/search/RecentContacts.tsx @@ -6,7 +6,7 @@ import { withGlobal } from '../../../lib/teact/teactn'; import { GlobalActions } from '../../../global/types'; import { ApiUser } from '../../../api/types'; -import { getUserFirstName } from '../../../modules/helpers'; +import { getUserFirstOrLastName } from '../../../modules/helpers'; import renderText from '../../common/helpers/renderText'; import { throttle } from '../../../util/schedulers'; import { pick } from '../../../util/iteratees'; @@ -79,7 +79,7 @@ const RecentContacts: FC = ({ {topUserIds.map((userId) => (

handleClick(userId)}> -
{renderText(getUserFirstName(usersById[userId]) || NBSP)}
+
{renderText(getUserFirstOrLastName(usersById[userId]) || NBSP)}
))} diff --git a/src/components/middle/DeleteSelectedMessagesModal.tsx b/src/components/middle/DeleteSelectedMessagesModal.tsx index 12ee8bac0..68d679fda 100644 --- a/src/components/middle/DeleteSelectedMessagesModal.tsx +++ b/src/components/middle/DeleteSelectedMessagesModal.tsx @@ -6,7 +6,7 @@ import { GlobalActions } from '../../global/types'; import { selectCanDeleteSelectedMessages, selectCurrentChat, selectUser } from '../../modules/selectors'; import { isChatPrivate, - getUserFirstName, + getUserFirstOrLastName, getPrivateChatUserId, isChatBasicGroup, isChatSuperGroup, @@ -27,7 +27,7 @@ export type OwnProps = { type StateProps = { selectedMessageIds?: number[]; canDeleteForAll?: boolean; - contactFirstName?: string; + contactName?: string; willDeleteForCurrentUserOnly?: boolean; willDeleteForAll?: boolean; }; @@ -39,7 +39,7 @@ const DeleteSelectedMessagesModal: FC = ( isSchedule, selectedMessageIds, canDeleteForAll, - contactFirstName, + contactName, willDeleteForCurrentUserOnly, willDeleteForAll, onClose, @@ -89,8 +89,8 @@ const DeleteSelectedMessagesModal: FC = ( )} {canDeleteForAll && ( )}