Removes showIdentity and showSafetyNumber in favor of redux action

This commit is contained in:
Josh Perez 2022-12-09 00:53:19 -05:00 committed by GitHub
parent 5043ac2e02
commit 135c832748
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 14 additions and 43 deletions

View file

@ -69,7 +69,7 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
interactionMode: 'keyboard', interactionMode: 'keyboard',
theme: ThemeType.light, theme: ThemeType.light,
showSafetyNumber: action('showSafetyNumber'), toggleSafetyNumberModal: action('toggleSafetyNumberModal'),
checkForAccount: action('checkForAccount'), checkForAccount: action('checkForAccount'),
clearSelectedMessage: action('clearSelectedMessage'), clearSelectedMessage: action('clearSelectedMessage'),

View file

@ -65,7 +65,6 @@ export type PropsData = {
receivedAt: number; receivedAt: number;
sentAt: number; sentAt: number;
showSafetyNumber: (contactId: string) => void;
i18n: LocalizerType; i18n: LocalizerType;
theme: ThemeType; theme: ThemeType;
getPreferredBadge: PreferredBadgeSelectorType; getPreferredBadge: PreferredBadgeSelectorType;
@ -101,7 +100,9 @@ export type PropsReduxActions = Pick<
| 'doubleCheckMissingQuoteReference' | 'doubleCheckMissingQuoteReference'
| 'checkForAccount' | 'checkForAccount'
| 'viewStory' | 'viewStory'
>; > & {
toggleSafetyNumberModal: (contactId: string) => void;
};
export type ExternalProps = PropsData & PropsBackboneActions; export type ExternalProps = PropsData & PropsBackboneActions;
export type Props = PropsData & PropsBackboneActions & PropsReduxActions; export type Props = PropsData & PropsBackboneActions & PropsReduxActions;
@ -162,7 +163,7 @@ export class MessageDetail extends React.Component<Props> {
} }
public renderContact(contact: Contact): JSX.Element { public renderContact(contact: Contact): JSX.Element {
const { i18n, showSafetyNumber } = this.props; const { i18n, toggleSafetyNumberModal } = this.props;
const errors = contact.errors || []; const errors = contact.errors || [];
const errorComponent = contact.isOutgoingKeyError ? ( const errorComponent = contact.isOutgoingKeyError ? (
@ -170,7 +171,7 @@ export class MessageDetail extends React.Component<Props> {
<button <button
type="button" type="button"
className="module-message-detail__contact__show-safety-number" className="module-message-detail__contact__show-safety-number"
onClick={() => showSafetyNumber(contact.id)} onClick={() => toggleSafetyNumberModal(contact.id)}
> >
{i18n('showSafetyNumber')} {i18n('showSafetyNumber')}
</button> </button>

View file

@ -21,7 +21,7 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n, i18n,
contact: overrideProps.contact || ({} as ContactType), contact: overrideProps.contact || ({} as ContactType),
isGroup: boolean('isGroup', overrideProps.isGroup || false), isGroup: boolean('isGroup', overrideProps.isGroup || false),
showIdentity: action('showIdentity'), toggleSafetyNumberModal: action('toggleSafetyNumberModal'),
}); });
export default { export default {

View file

@ -24,7 +24,7 @@ type PropsHousekeeping = {
}; };
export type PropsActions = { export type PropsActions = {
showIdentity: (id: string) => void; toggleSafetyNumberModal: (id: string) => void;
}; };
export type Props = PropsData & PropsHousekeeping & PropsActions; export type Props = PropsData & PropsHousekeeping & PropsActions;
@ -33,7 +33,7 @@ export function SafetyNumberNotification({
contact, contact,
isGroup, isGroup,
i18n, i18n,
showIdentity, toggleSafetyNumberModal,
}: Props): JSX.Element { }: Props): JSX.Element {
const changeKey = isGroup const changeKey = isGroup
? 'safetyNumberChangedGroup' ? 'safetyNumberChangedGroup'
@ -62,7 +62,7 @@ export function SafetyNumberNotification({
button={ button={
<Button <Button
onClick={() => { onClick={() => {
showIdentity(contact.id); toggleSafetyNumberModal(contact.id);
}} }}
size={ButtonSize.Small} size={ButtonSize.Small}
variant={ButtonVariant.SystemMessage} variant={ButtonVariant.SystemMessage}

View file

@ -305,7 +305,7 @@ const actions = () => ({
), ),
toggleForwardMessageModal: action('toggleForwardMessageModal'), toggleForwardMessageModal: action('toggleForwardMessageModal'),
showIdentity: action('showIdentity'), toggleSafetyNumberModal: action('toggleSafetyNumberModal'),
downloadNewVersion: action('downloadNewVersion'), downloadNewVersion: action('downloadNewVersion'),

View file

@ -262,7 +262,7 @@ const getActions = createSelector(
'showExpiredOutgoingTapToViewToast', 'showExpiredOutgoingTapToViewToast',
'startConversation', 'startConversation',
'showIdentity', 'toggleSafetyNumberModal',
'downloadNewVersion', 'downloadNewVersion',

View file

@ -96,7 +96,7 @@ const getDefaultProps = () => ({
openLink: action('openLink'), openLink: action('openLink'),
scrollToQuotedMessage: action('scrollToQuotedMessage'), scrollToQuotedMessage: action('scrollToQuotedMessage'),
downloadNewVersion: action('downloadNewVersion'), downloadNewVersion: action('downloadNewVersion'),
showIdentity: action('showIdentity'), toggleSafetyNumberModal: action('toggleSafetyNumberModal'),
startCallingLobby: action('startCallingLobby'), startCallingLobby: action('startCallingLobby'),
startConversation: action('startConversation'), startConversation: action('startConversation'),
returnToActiveCall: action('returnToActiveCall'), returnToActiveCall: action('returnToActiveCall'),

View file

@ -38,8 +38,6 @@ const mapStateToProps = (
receivedAt, receivedAt,
sentAt, sentAt,
showSafetyNumber,
displayTapToViewMessage, displayTapToViewMessage,
kickOffAttachmentDownload, kickOffAttachmentDownload,
markAttachmentAsCorrupted, markAttachmentAsCorrupted,
@ -77,8 +75,6 @@ const mapStateToProps = (
interactionMode: getInteractionMode(state), interactionMode: getInteractionMode(state),
theme: getTheme(state), theme: getTheme(state),
showSafetyNumber,
displayTapToViewMessage, displayTapToViewMessage,
kickOffAttachmentDownload, kickOffAttachmentDownload,
markAttachmentAsCorrupted, markAttachmentAsCorrupted,

View file

@ -89,7 +89,6 @@ export type TimelinePropsType = ExternalProps &
| 'showContactModal' | 'showContactModal'
| 'showExpiredIncomingTapToViewToast' | 'showExpiredIncomingTapToViewToast'
| 'showExpiredOutgoingTapToViewToast' | 'showExpiredOutgoingTapToViewToast'
| 'showIdentity'
| 'showMessageDetail' | 'showMessageDetail'
| 'showVisualAttachment' | 'showVisualAttachment'
| 'startConversation' | 'startConversation'

View file

@ -21,7 +21,7 @@ import { getContactId } from '../messages/helpers';
import { strictAssert } from '../util/assert'; import { strictAssert } from '../util/assert';
import { enqueueReactionForSend } from '../reactions/enqueueReactionForSend'; import { enqueueReactionForSend } from '../reactions/enqueueReactionForSend';
import type { GroupNameCollisionsWithIdsByTitle } from '../util/groupMemberNameCollisions'; import type { GroupNameCollisionsWithIdsByTitle } from '../util/groupMemberNameCollisions';
import { isDirectConversation, isGroup } from '../util/whatTypeOfConversation'; import { isGroup } from '../util/whatTypeOfConversation';
import { findAndFormatContact } from '../util/findAndFormatContact'; import { findAndFormatContact } from '../util/findAndFormatContact';
import { getPreferredBadgeSelector } from '../state/selectors/badges'; import { getPreferredBadgeSelector } from '../state/selectors/badges';
import { import {
@ -125,10 +125,8 @@ type MessageActionsType = {
}; };
}) => unknown; }) => unknown;
showContactModal: (contactId: string) => unknown; showContactModal: (contactId: string) => unknown;
showSafetyNumber: (contactId: string) => unknown;
showExpiredIncomingTapToViewToast: () => unknown; showExpiredIncomingTapToViewToast: () => unknown;
showExpiredOutgoingTapToViewToast: () => unknown; showExpiredOutgoingTapToViewToast: () => unknown;
showIdentity: (conversationId: string) => unknown;
showMessageDetail: (messageId: string) => unknown; showMessageDetail: (messageId: string) => unknown;
showVisualAttachment: (options: { showVisualAttachment: (options: {
attachment: AttachmentType; attachment: AttachmentType;
@ -528,9 +526,6 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
}; };
const displayTapToViewMessage = (messageId: string) => const displayTapToViewMessage = (messageId: string) =>
this.displayTapToViewMessage(messageId); this.displayTapToViewMessage(messageId);
const showIdentity = (conversationId: string) => {
this.showSafetyNumber(conversationId);
};
const openGiftBadge = (messageId: string): void => { const openGiftBadge = (messageId: string): void => {
const message = window.MessageController.getById(messageId); const message = window.MessageController.getById(messageId);
if (!message) { if (!message) {
@ -546,9 +541,6 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
const downloadNewVersion = () => { const downloadNewVersion = () => {
openLinkInWebBrowser('https://signal.org/download'); openLinkInWebBrowser('https://signal.org/download');
}; };
const showSafetyNumber = (contactId: string) => {
this.showSafetyNumber(contactId);
};
const showExpiredIncomingTapToViewToast = () => { const showExpiredIncomingTapToViewToast = () => {
log.info('Showing expired tap-to-view toast for an incoming message'); log.info('Showing expired tap-to-view toast for an incoming message');
showToast(ToastTapToViewExpiredIncoming); showToast(ToastTapToViewExpiredIncoming);
@ -574,10 +566,8 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
retryDeleteForEveryone, retryDeleteForEveryone,
showContactDetail, showContactDetail,
showContactModal, showContactModal,
showSafetyNumber,
showExpiredIncomingTapToViewToast, showExpiredIncomingTapToViewToast,
showExpiredOutgoingTapToViewToast, showExpiredOutgoingTapToViewToast,
showIdentity,
showMessageDetail, showMessageDetail,
showVisualAttachment, showVisualAttachment,
startConversation, startConversation,
@ -973,21 +963,6 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
view.render(); view.render();
} }
showSafetyNumber(id?: string): void {
let conversation: undefined | ConversationModel;
if (!id && isDirectConversation(this.model.attributes)) {
conversation = this.model;
} else {
conversation = window.ConversationController.get(id);
}
if (conversation) {
window.reduxActions.globalModals.toggleSafetyNumberModal(
conversation.get('id')
);
}
}
downloadAttachmentWrapper( downloadAttachmentWrapper(
messageId: string, messageId: string,
providedAttachment?: AttachmentType providedAttachment?: AttachmentType