signal-desktop/ts/state/smart/MessageDetail.tsx

103 lines
2.5 KiB
TypeScript
Raw Normal View History

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { connect } from 'react-redux';
import type { ExternalProps as MessageDetailProps } from '../../components/conversation/MessageDetail';
import { MessageDetail } from '../../components/conversation/MessageDetail';
import { mapDispatchToProps } from '../actions';
import type { StateType } from '../reducer';
import { getIntl, getInteractionMode, getTheme } from '../selectors/user';
import { renderAudioAttachment } from './renderAudioAttachment';
import { renderEmojiPicker } from './renderEmojiPicker';
import { renderReactionPicker } from './renderReactionPicker';
2021-06-07 16:50:18 +00:00
import { getContactNameColorSelector } from '../selectors/conversations';
2021-05-10 22:38:18 +00:00
export { Contact } from '../../components/conversation/MessageDetail';
2021-08-30 21:32:56 +00:00
export type OwnProps = Omit<
MessageDetailProps,
| 'i18n'
| 'interactionMode'
| 'renderAudioAttachment'
| 'renderEmojiPicker'
| 'renderReactionPicker'
| 'theme'
>;
const mapStateToProps = (
state: StateType,
props: OwnProps
): MessageDetailProps => {
const {
contacts,
errors,
message,
receivedAt,
sentAt,
showSafetyNumber,
displayTapToViewMessage,
kickOffAttachmentDownload,
markAttachmentAsCorrupted,
markViewed,
openConversation,
openLink,
reactToMessage,
replyToMessage,
retrySend,
showContactDetail,
showContactModal,
showExpiredIncomingTapToViewToast,
showExpiredOutgoingTapToViewToast,
2021-04-27 22:35:35 +00:00
showForwardMessageModal,
showVisualAttachment,
} = props;
2021-06-07 16:50:18 +00:00
const contactNameColor =
message.conversationType === 'group'
? getContactNameColorSelector(state)(
message.conversationId,
message.author.id
)
: undefined;
return {
contacts,
2021-06-07 16:50:18 +00:00
contactNameColor,
errors,
message,
receivedAt,
sentAt,
i18n: getIntl(state),
interactionMode: getInteractionMode(state),
theme: getTheme(state),
showSafetyNumber,
displayTapToViewMessage,
kickOffAttachmentDownload,
markAttachmentAsCorrupted,
markViewed,
openConversation,
openLink,
reactToMessage,
renderAudioAttachment,
renderEmojiPicker,
renderReactionPicker,
replyToMessage,
retrySend,
showContactDetail,
showContactModal,
showExpiredIncomingTapToViewToast,
showExpiredOutgoingTapToViewToast,
2021-04-27 22:35:35 +00:00
showForwardMessageModal,
showVisualAttachment,
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartMessageDetail = smart(MessageDetail);