Show badges in contact spoofing dialog

This commit is contained in:
Evan Hahn 2021-11-30 04:07:24 -06:00 committed by GitHub
parent 599c7afe8b
commit a7ca634e87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 3 deletions

View file

@ -11,6 +11,7 @@ import { getDefaultConversation } from '../../test-both/helpers/getDefaultConver
import { ContactSpoofingReviewDialog } from './ContactSpoofingReviewDialog'; import { ContactSpoofingReviewDialog } from './ContactSpoofingReviewDialog';
import { ContactSpoofingType } from '../../util/contactSpoofing'; import { ContactSpoofingType } from '../../util/contactSpoofing';
import { ThemeType } from '../../types/Util';
const i18n = setupI18n('en', enMessages); const i18n = setupI18n('en', enMessages);
@ -20,6 +21,7 @@ const story = storiesOf(
); );
const getCommonProps = () => ({ const getCommonProps = () => ({
getPreferredBadge: () => undefined,
i18n, i18n,
onBlock: action('onBlock'), onBlock: action('onBlock'),
onBlockAndReportSpam: action('onBlockAndReportSpam'), onBlockAndReportSpam: action('onBlockAndReportSpam'),
@ -28,6 +30,7 @@ const getCommonProps = () => ({
onShowContactModal: action('onShowContactModal'), onShowContactModal: action('onShowContactModal'),
onUnblock: action('onUnblock'), onUnblock: action('onUnblock'),
removeMember: action('removeMember'), removeMember: action('removeMember'),
theme: ThemeType.light,
}); });
story.add('Direct conversations with same title', () => ( story.add('Direct conversations with same title', () => (

View file

@ -5,8 +5,9 @@ import type { FunctionComponent, ReactChild, ReactNode } from 'react';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { concat, orderBy } from 'lodash'; import { concat, orderBy } from 'lodash';
import type { LocalizerType } 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 { import {
MessageRequestActionsConfirmation, MessageRequestActionsConfirmation,
MessageRequestState, MessageRequestState,
@ -24,6 +25,7 @@ import { missingCaseError } from '../../util/missingCaseError';
import { isInSystemContacts } from '../../util/isInSystemContacts'; import { isInSystemContacts } from '../../util/isInSystemContacts';
type PropsType = { type PropsType = {
getPreferredBadge: PreferredBadgeSelectorType;
i18n: LocalizerType; i18n: LocalizerType;
onBlock: (conversationId: string) => unknown; onBlock: (conversationId: string) => unknown;
onBlockAndReportSpam: (conversationId: string) => unknown; onBlockAndReportSpam: (conversationId: string) => unknown;
@ -32,6 +34,7 @@ type PropsType = {
onShowContactModal: (contactId: string) => unknown; onShowContactModal: (contactId: string) => unknown;
onUnblock: (conversationId: string) => unknown; onUnblock: (conversationId: string) => unknown;
removeMember: (conversationId: string) => unknown; removeMember: (conversationId: string) => unknown;
theme: ThemeType;
} & ( } & (
| { | {
type: ContactSpoofingType.DirectConversationWithSameTitle; type: ContactSpoofingType.DirectConversationWithSameTitle;
@ -60,6 +63,7 @@ enum ConfirmationStateType {
export const ContactSpoofingReviewDialog: FunctionComponent<PropsType> = export const ContactSpoofingReviewDialog: FunctionComponent<PropsType> =
props => { props => {
const { const {
getPreferredBadge,
i18n, i18n,
onBlock, onBlock,
onBlockAndReportSpam, onBlockAndReportSpam,
@ -68,6 +72,7 @@ export const ContactSpoofingReviewDialog: FunctionComponent<PropsType> =
onShowContactModal, onShowContactModal,
onUnblock, onUnblock,
removeMember, removeMember,
theme,
} = props; } = props;
const [confirmationState, setConfirmationState] = useState< const [confirmationState, setConfirmationState] = useState<
@ -177,7 +182,9 @@ export const ContactSpoofingReviewDialog: FunctionComponent<PropsType> =
</h2> </h2>
<ContactSpoofingReviewDialogPerson <ContactSpoofingReviewDialogPerson
conversation={possiblyUnsafeConversation} conversation={possiblyUnsafeConversation}
getPreferredBadge={getPreferredBadge}
i18n={i18n} i18n={i18n}
theme={theme}
> >
<div className="module-ContactSpoofingReviewDialog__buttons"> <div className="module-ContactSpoofingReviewDialog__buttons">
<Button <Button
@ -208,10 +215,12 @@ export const ContactSpoofingReviewDialog: FunctionComponent<PropsType> =
<h2>{i18n('ContactSpoofingReviewDialog__safe-title')}</h2> <h2>{i18n('ContactSpoofingReviewDialog__safe-title')}</h2>
<ContactSpoofingReviewDialogPerson <ContactSpoofingReviewDialogPerson
conversation={safeConversation} conversation={safeConversation}
getPreferredBadge={getPreferredBadge}
i18n={i18n} i18n={i18n}
onClick={() => { onClick={() => {
onShowContactModal(safeConversation.id); onShowContactModal(safeConversation.id);
}} }}
theme={theme}
/> />
</> </>
); );
@ -297,7 +306,9 @@ export const ContactSpoofingReviewDialog: FunctionComponent<PropsType> =
<ContactSpoofingReviewDialogPerson <ContactSpoofingReviewDialogPerson
key={conversationInfo.conversation.id} key={conversationInfo.conversation.id}
conversation={conversationInfo.conversation} conversation={conversationInfo.conversation}
getPreferredBadge={getPreferredBadge}
i18n={i18n} i18n={i18n}
theme={theme}
> >
{Boolean(oldName) && oldName !== newName && ( {Boolean(oldName) && oldName !== newName && (
<div className="module-ContactSpoofingReviewDialogPerson__info__property module-ContactSpoofingReviewDialogPerson__info__property--callout"> <div className="module-ContactSpoofingReviewDialogPerson__info__property module-ContactSpoofingReviewDialogPerson__info__property--callout">

View file

@ -5,7 +5,8 @@ import type { FunctionComponent, ReactNode } from 'react';
import React from 'react'; import React from 'react';
import type { ConversationType } from '../../state/ducks/conversations'; import type { ConversationType } from '../../state/ducks/conversations';
import type { LocalizerType } from '../../types/Util'; import type { LocalizerType, ThemeType } from '../../types/Util';
import type { PreferredBadgeSelectorType } from '../../state/selectors/badges';
import { assert } from '../../util/assert'; import { assert } from '../../util/assert';
import { Avatar, AvatarSize } from '../Avatar'; import { Avatar, AvatarSize } from '../Avatar';
@ -15,12 +16,14 @@ import { SharedGroupNames } from '../SharedGroupNames';
type PropsType = { type PropsType = {
children?: ReactNode; children?: ReactNode;
conversation: ConversationType; conversation: ConversationType;
getPreferredBadge: PreferredBadgeSelectorType;
i18n: LocalizerType; i18n: LocalizerType;
onClick?: () => void; onClick?: () => void;
theme: ThemeType;
}; };
export const ContactSpoofingReviewDialogPerson: FunctionComponent<PropsType> = export const ContactSpoofingReviewDialogPerson: FunctionComponent<PropsType> =
({ children, conversation, i18n, onClick }) => { ({ children, conversation, getPreferredBadge, i18n, onClick, theme }) => {
assert( assert(
conversation.type === 'direct', conversation.type === 'direct',
'<ContactSpoofingReviewDialogPerson> expected a direct conversation' '<ContactSpoofingReviewDialogPerson> expected a direct conversation'
@ -30,10 +33,12 @@ export const ContactSpoofingReviewDialogPerson: FunctionComponent<PropsType> =
<> <>
<Avatar <Avatar
{...conversation} {...conversation}
badge={getPreferredBadge(conversation.badges)}
conversationType={conversation.type} conversationType={conversation.type}
size={AvatarSize.FIFTY_TWO} size={AvatarSize.FIFTY_TWO}
className="module-ContactSpoofingReviewDialogPerson__avatar" className="module-ContactSpoofingReviewDialogPerson__avatar"
i18n={i18n} i18n={i18n}
theme={theme}
/> />
<div className="module-ContactSpoofingReviewDialogPerson__info"> <div className="module-ContactSpoofingReviewDialogPerson__info">
<ContactName <ContactName

View file

@ -1492,6 +1492,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
let contactSpoofingReviewDialog: ReactNode; let contactSpoofingReviewDialog: ReactNode;
if (contactSpoofingReview) { if (contactSpoofingReview) {
const commonProps = { const commonProps = {
getPreferredBadge,
i18n, i18n,
onBlock, onBlock,
onBlockAndReportSpam, onBlockAndReportSpam,
@ -1500,6 +1501,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
onShowContactModal: showContactModal, onShowContactModal: showContactModal,
onUnblock, onUnblock,
removeMember, removeMember,
theme,
}; };
switch (contactSpoofingReview.type) { switch (contactSpoofingReview.type) {