From 59b135ad7ec1f1fe2817b65c38a393879f1afc37 Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Thu, 8 Feb 2024 09:36:08 -0500 Subject: [PATCH] Allow viewing contact details from group change messages --- stylesheets/components/ContactName.scss | 16 ++++++++++++++++ ts/components/conversation/ContactName.tsx | 9 ++++++--- ts/state/smart/ContactName.tsx | 21 +++++++++++++++------ ts/state/smart/TimelineItem.tsx | 4 ++-- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/stylesheets/components/ContactName.scss b/stylesheets/components/ContactName.scss index accfcd5dd2b..bdf7be6ce90 100644 --- a/stylesheets/components/ContactName.scss +++ b/stylesheets/components/ContactName.scss @@ -1,6 +1,22 @@ // Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only +button.module-contact-name { + @include button-reset; + + &:hover, + &:focus { + text-decoration: underline; + } + + &:focus { + @include keyboard-mode { + outline: auto; + text-decoration: none; + } + } +} + .module-contact-name { &--000 { color: #d00b0b; diff --git a/ts/components/conversation/ContactName.tsx b/ts/components/conversation/ContactName.tsx index 8c9c7055fd0..d5ad60f791c 100644 --- a/ts/components/conversation/ContactName.tsx +++ b/ts/components/conversation/ContactName.tsx @@ -16,6 +16,7 @@ export type PropsType = { module?: string; preferFirstName?: boolean; title: string; + onClick?: VoidFunction; }; export function ContactName({ @@ -26,6 +27,7 @@ export function ContactName({ module, preferFirstName, title, + onClick, }: PropsType): JSX.Element { const getClassName = getClassNamesFor('module-contact-name', module); @@ -35,19 +37,20 @@ export function ContactName({ } else { text = title || ''; } - + const WrappingElement = onClick ? 'button' : 'span'; return ( - {(isSignalConversation || isMe) && ( )} - + ); } diff --git a/ts/state/smart/ContactName.tsx b/ts/state/smart/ContactName.tsx index b14f2dcff08..43872d729df 100644 --- a/ts/state/smart/ContactName.tsx +++ b/ts/state/smart/ContactName.tsx @@ -9,29 +9,38 @@ import { ContactName } from '../../components/conversation/ContactName'; import { getIntl } from '../selectors/user'; import type { GetConversationByIdType } from '../selectors/conversations'; -import { getConversationSelector } from '../selectors/conversations'; +import { + getConversationSelector, + getSelectedConversationId, +} from '../selectors/conversations'; import type { LocalizerType } from '../../types/Util'; +import { useGlobalModalActions } from '../ducks/globalModals'; type ExternalProps = { - conversationId: string; + contactId: string; }; export function SmartContactName(props: ExternalProps): JSX.Element { - const { conversationId } = props; + const { contactId } = props; const i18n = useSelector(getIntl); const getConversation = useSelector( getConversationSelector ); - const conversation = getConversation(conversationId) || { + const contact = getConversation(contactId) || { title: i18n('icu:unknownContact'), }; + const currentConversationId = useSelector(getSelectedConversationId); + const currentConversation = getConversation(currentConversationId); + + const { showContactModal } = useGlobalModalActions(); return ( showContactModal(contact.id, currentConversation.id)} /> ); } diff --git a/ts/state/smart/TimelineItem.tsx b/ts/state/smart/TimelineItem.tsx index 034df41294b..dd787ede63c 100644 --- a/ts/state/smart/TimelineItem.tsx +++ b/ts/state/smart/TimelineItem.tsx @@ -48,8 +48,8 @@ type ExternalProps = { unreadIndicatorPlacement: undefined | UnreadIndicatorPlacement; }; -function renderContact(conversationId: string): JSX.Element { - return ; +function renderContact(contactId: string): JSX.Element { + return ; } function renderUniversalTimerNotification(): JSX.Element {