Skip to content

Commit

Permalink
Allow viewing contact details from group change messages
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-signal committed Feb 8, 2024
1 parent 614bb90 commit 59b135a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
16 changes: 16 additions & 0 deletions 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;
Expand Down
9 changes: 6 additions & 3 deletions ts/components/conversation/ContactName.tsx
Expand Up @@ -16,6 +16,7 @@ export type PropsType = {
module?: string;
preferFirstName?: boolean;
title: string;
onClick?: VoidFunction;
};

export function ContactName({
Expand All @@ -26,6 +27,7 @@ export function ContactName({
module,
preferFirstName,
title,
onClick,
}: PropsType): JSX.Element {
const getClassName = getClassNamesFor('module-contact-name', module);

Expand All @@ -35,19 +37,20 @@ export function ContactName({
} else {
text = title || '';
}

const WrappingElement = onClick ? 'button' : 'span';
return (
<span
<WrappingElement
className={classNames(
getClassName(''),
contactNameColor ? getClassName(`--${contactNameColor}`) : null
)}
dir="auto"
onClick={onClick}
>
<Emojify text={text} />
{(isSignalConversation || isMe) && (
<span className="ContactModal__official-badge" />
)}
</span>
</WrappingElement>
);
}
21 changes: 15 additions & 6 deletions ts/state/smart/ContactName.tsx
Expand Up @@ -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<StateType, LocalizerType>(getIntl);
const getConversation = useSelector<StateType, GetConversationByIdType>(
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 (
<ContactName
firstName={conversation.firstName}
title={conversation.title}
firstName={contact.firstName}
title={contact.title}
onClick={() => showContactModal(contact.id, currentConversation.id)}
/>
);
}
4 changes: 2 additions & 2 deletions ts/state/smart/TimelineItem.tsx
Expand Up @@ -48,8 +48,8 @@ type ExternalProps = {
unreadIndicatorPlacement: undefined | UnreadIndicatorPlacement;
};

function renderContact(conversationId: string): JSX.Element {
return <SmartContactName conversationId={conversationId} />;
function renderContact(contactId: string): JSX.Element {
return <SmartContactName contactId={contactId} />;
}

function renderUniversalTimerNotification(): JSX.Element {
Expand Down

0 comments on commit 59b135a

Please sign in to comment.