2021-03-24 22:06:12 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ExternalProps as MessageDetailProps } from '../../components/conversation/MessageDetail';
|
|
|
|
import { MessageDetail } from '../../components/conversation/MessageDetail';
|
2021-03-24 22:06:12 +00:00
|
|
|
|
2021-07-20 19:56:50 +00:00
|
|
|
import { mapDispatchToProps } from '../actions';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2021-11-15 22:53:42 +00:00
|
|
|
import { getIntl, getInteractionMode, getTheme } from '../selectors/user';
|
2021-03-24 22:06:12 +00:00
|
|
|
import { renderAudioAttachment } from './renderAudioAttachment';
|
|
|
|
import { renderEmojiPicker } from './renderEmojiPicker';
|
2021-09-10 18:00:31 +00:00
|
|
|
import { renderReactionPicker } from './renderReactionPicker';
|
2021-06-07 16:50:18 +00:00
|
|
|
import { getContactNameColorSelector } from '../selectors/conversations';
|
2021-03-24 22:06:12 +00:00
|
|
|
|
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<
|
2021-03-24 22:06:12 +00:00
|
|
|
MessageDetailProps,
|
2021-09-10 18:00:31 +00:00
|
|
|
| 'i18n'
|
|
|
|
| 'interactionMode'
|
|
|
|
| 'renderAudioAttachment'
|
|
|
|
| 'renderEmojiPicker'
|
|
|
|
| 'renderReactionPicker'
|
2021-11-15 22:53:42 +00:00
|
|
|
| 'theme'
|
2021-03-24 22:06:12 +00:00
|
|
|
>;
|
|
|
|
|
|
|
|
const mapStateToProps = (
|
|
|
|
state: StateType,
|
|
|
|
props: OwnProps
|
|
|
|
): MessageDetailProps => {
|
|
|
|
const {
|
|
|
|
contacts,
|
|
|
|
errors,
|
|
|
|
message,
|
|
|
|
receivedAt,
|
|
|
|
sentAt,
|
|
|
|
|
2021-06-16 00:44:14 +00:00
|
|
|
showSafetyNumber,
|
|
|
|
|
2021-03-24 22:06:12 +00:00
|
|
|
displayTapToViewMessage,
|
|
|
|
kickOffAttachmentDownload,
|
|
|
|
markAttachmentAsCorrupted,
|
2021-08-12 18:15:55 +00:00
|
|
|
markViewed,
|
2021-03-24 22:06:12 +00:00
|
|
|
openConversation,
|
|
|
|
openLink,
|
|
|
|
reactToMessage,
|
|
|
|
replyToMessage,
|
|
|
|
retrySend,
|
|
|
|
showContactDetail,
|
|
|
|
showContactModal,
|
|
|
|
showExpiredIncomingTapToViewToast,
|
|
|
|
showExpiredOutgoingTapToViewToast,
|
2021-04-27 22:35:35 +00:00
|
|
|
showForwardMessageModal,
|
2021-03-24 22:06:12 +00:00
|
|
|
showVisualAttachment,
|
|
|
|
} = props;
|
|
|
|
|
2021-06-07 16:50:18 +00:00
|
|
|
const contactNameColor =
|
|
|
|
message.conversationType === 'group'
|
|
|
|
? getContactNameColorSelector(state)(
|
|
|
|
message.conversationId,
|
|
|
|
message.author.id
|
|
|
|
)
|
|
|
|
: undefined;
|
|
|
|
|
2021-03-24 22:06:12 +00:00
|
|
|
return {
|
|
|
|
contacts,
|
2021-06-07 16:50:18 +00:00
|
|
|
contactNameColor,
|
2021-03-24 22:06:12 +00:00
|
|
|
errors,
|
|
|
|
message,
|
|
|
|
receivedAt,
|
|
|
|
sentAt,
|
|
|
|
|
|
|
|
i18n: getIntl(state),
|
|
|
|
interactionMode: getInteractionMode(state),
|
2021-11-15 22:53:42 +00:00
|
|
|
theme: getTheme(state),
|
2021-03-24 22:06:12 +00:00
|
|
|
|
2021-06-16 00:44:14 +00:00
|
|
|
showSafetyNumber,
|
|
|
|
|
2021-03-24 22:06:12 +00:00
|
|
|
displayTapToViewMessage,
|
|
|
|
kickOffAttachmentDownload,
|
|
|
|
markAttachmentAsCorrupted,
|
2021-08-12 18:15:55 +00:00
|
|
|
markViewed,
|
2021-03-24 22:06:12 +00:00
|
|
|
openConversation,
|
|
|
|
openLink,
|
|
|
|
reactToMessage,
|
|
|
|
renderAudioAttachment,
|
|
|
|
renderEmojiPicker,
|
2021-09-10 18:00:31 +00:00
|
|
|
renderReactionPicker,
|
2021-03-24 22:06:12 +00:00
|
|
|
replyToMessage,
|
|
|
|
retrySend,
|
|
|
|
showContactDetail,
|
|
|
|
showContactModal,
|
|
|
|
showExpiredIncomingTapToViewToast,
|
|
|
|
showExpiredOutgoingTapToViewToast,
|
2021-04-27 22:35:35 +00:00
|
|
|
showForwardMessageModal,
|
2021-03-24 22:06:12 +00:00
|
|
|
showVisualAttachment,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
export const SmartMessageDetail = smart(MessageDetail);
|