Show user badges on message details screen

This commit is contained in:
Evan Hahn 2021-11-16 09:53:41 -06:00 committed by GitHub
parent 4a055d4b95
commit a466b939bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -62,6 +62,7 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
receivedAt: number('receivedAt', overrideProps.receivedAt || Date.now()), receivedAt: number('receivedAt', overrideProps.receivedAt || Date.now()),
sentAt: number('sentAt', overrideProps.sentAt || Date.now()), sentAt: number('sentAt', overrideProps.sentAt || Date.now()),
getPreferredBadge: () => getFakeBadge(),
i18n, i18n,
interactionMode: 'keyboard', interactionMode: 'keyboard',
theme: ThemeType.light, theme: ThemeType.light,

View File

@ -16,6 +16,7 @@ import type {
import { Message } from './Message'; import { Message } from './Message';
import type { LocalizerType, ThemeType } from '../../types/Util'; import type { LocalizerType, ThemeType } from '../../types/Util';
import type { ConversationType } from '../../state/ducks/conversations'; import type { ConversationType } from '../../state/ducks/conversations';
import type { PreferredBadgeSelectorType } from '../../state/selectors/badges';
import { groupBy } from '../../util/mapUtil'; import { groupBy } from '../../util/mapUtil';
import type { ContactNameColorType } from '../../types/Colors'; import type { ContactNameColorType } from '../../types/Colors';
import { SendStatus } from '../../messages/MessageSendState'; import { SendStatus } from '../../messages/MessageSendState';
@ -27,6 +28,7 @@ export type Contact = Pick<
ConversationType, ConversationType,
| 'acceptedMessageRequest' | 'acceptedMessageRequest'
| 'avatarPath' | 'avatarPath'
| 'badges'
| 'color' | 'color'
| 'id' | 'id'
| 'isMe' | 'isMe'
@ -61,6 +63,7 @@ export type PropsData = {
showSafetyNumber: (contactId: string) => void; showSafetyNumber: (contactId: string) => void;
i18n: LocalizerType; i18n: LocalizerType;
theme: ThemeType; theme: ThemeType;
getPreferredBadge: PreferredBadgeSelectorType;
} & Pick<MessagePropsType, 'interactionMode'>; } & Pick<MessagePropsType, 'interactionMode'>;
export type PropsBackboneActions = Pick< export type PropsBackboneActions = Pick<
@ -117,10 +120,11 @@ export class MessageDetail extends React.Component<Props> {
} }
public renderAvatar(contact: Contact): JSX.Element { public renderAvatar(contact: Contact): JSX.Element {
const { i18n } = this.props; const { getPreferredBadge, i18n, theme } = this.props;
const { const {
acceptedMessageRequest, acceptedMessageRequest,
avatarPath, avatarPath,
badges,
color, color,
isMe, isMe,
name, name,
@ -135,6 +139,7 @@ export class MessageDetail extends React.Component<Props> {
<Avatar <Avatar
acceptedMessageRequest={acceptedMessageRequest} acceptedMessageRequest={acceptedMessageRequest}
avatarPath={avatarPath} avatarPath={avatarPath}
badge={getPreferredBadge(badges)}
color={color} color={color}
conversationType="direct" conversationType="direct"
i18n={i18n} i18n={i18n}
@ -142,6 +147,7 @@ export class MessageDetail extends React.Component<Props> {
name={name} name={name}
phoneNumber={phoneNumber} phoneNumber={phoneNumber}
profileName={profileName} profileName={profileName}
theme={theme}
title={title} title={title}
sharedGroupNames={sharedGroupNames} sharedGroupNames={sharedGroupNames}
size={AvatarSize.THIRTY_SIX} size={AvatarSize.THIRTY_SIX}

View File

@ -8,6 +8,7 @@ import { MessageDetail } from '../../components/conversation/MessageDetail';
import { mapDispatchToProps } from '../actions'; import { mapDispatchToProps } from '../actions';
import type { StateType } from '../reducer'; import type { StateType } from '../reducer';
import { getPreferredBadgeSelector } from '../selectors/badges';
import { getIntl, getInteractionMode, getTheme } from '../selectors/user'; import { getIntl, getInteractionMode, getTheme } from '../selectors/user';
import { renderAudioAttachment } from './renderAudioAttachment'; import { renderAudioAttachment } from './renderAudioAttachment';
import { renderEmojiPicker } from './renderEmojiPicker'; import { renderEmojiPicker } from './renderEmojiPicker';
@ -17,6 +18,7 @@ import { getContactNameColorSelector } from '../selectors/conversations';
export { Contact } from '../../components/conversation/MessageDetail'; export { Contact } from '../../components/conversation/MessageDetail';
export type OwnProps = Omit< export type OwnProps = Omit<
MessageDetailProps, MessageDetailProps,
| 'getPreferredBadge'
| 'i18n' | 'i18n'
| 'interactionMode' | 'interactionMode'
| 'renderAudioAttachment' | 'renderAudioAttachment'
@ -63,6 +65,8 @@ const mapStateToProps = (
) )
: undefined; : undefined;
const getPreferredBadge = getPreferredBadgeSelector(state);
return { return {
contacts, contacts,
contactNameColor, contactNameColor,
@ -71,6 +75,7 @@ const mapStateToProps = (
receivedAt, receivedAt,
sentAt, sentAt,
getPreferredBadge,
i18n: getIntl(state), i18n: getIntl(state),
interactionMode: getInteractionMode(state), interactionMode: getInteractionMode(state),
theme: getTheme(state), theme: getTheme(state),