2021-03-24 22:06:12 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { ComponentProps } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2021-07-20 19:56:50 +00:00
|
|
|
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-03-24 22:06:12 +00:00
|
|
|
import { StateType } from '../reducer';
|
|
|
|
import { getIntl, getInteractionMode } from '../selectors/user';
|
|
|
|
import { renderAudioAttachment } from './renderAudioAttachment';
|
|
|
|
import { renderEmojiPicker } from './renderEmojiPicker';
|
2021-06-07 16:50:18 +00:00
|
|
|
import { getContactNameColorSelector } from '../selectors/conversations';
|
2021-03-24 22:06:12 +00:00
|
|
|
|
|
|
|
type MessageDetailProps = ComponentProps<typeof MessageDetail>;
|
|
|
|
|
2021-05-10 22:38:18 +00:00
|
|
|
export { Contact } from '../../components/conversation/MessageDetail';
|
|
|
|
|
2021-07-20 19:56:50 +00:00
|
|
|
export type OwnProps = Pick<
|
2021-03-24 22:06:12 +00:00
|
|
|
MessageDetailProps,
|
|
|
|
| 'clearSelectedMessage'
|
2021-06-17 17:15:10 +00:00
|
|
|
| 'checkForAccount'
|
2021-07-20 19:56:50 +00:00
|
|
|
| 'contacts'
|
2021-03-24 22:06:12 +00:00
|
|
|
| 'deleteMessage'
|
|
|
|
| 'deleteMessageForEveryone'
|
|
|
|
| 'displayTapToViewMessage'
|
|
|
|
| 'downloadAttachment'
|
2021-06-17 17:15:10 +00:00
|
|
|
| 'doubleCheckMissingQuoteReference'
|
2021-07-20 19:56:50 +00:00
|
|
|
| 'errors'
|
2021-03-24 22:06:12 +00:00
|
|
|
| 'kickOffAttachmentDownload'
|
|
|
|
| 'markAttachmentAsCorrupted'
|
2021-08-12 18:15:55 +00:00
|
|
|
| 'markViewed'
|
2021-07-20 19:56:50 +00:00
|
|
|
| 'message'
|
2021-03-24 22:06:12 +00:00
|
|
|
| 'openConversation'
|
|
|
|
| 'openLink'
|
|
|
|
| 'reactToMessage'
|
2021-07-20 19:56:50 +00:00
|
|
|
| 'receivedAt'
|
2021-03-24 22:06:12 +00:00
|
|
|
| 'replyToMessage'
|
|
|
|
| 'retrySend'
|
2021-07-20 19:56:50 +00:00
|
|
|
| 'sendAnyway'
|
|
|
|
| 'sentAt'
|
2021-03-24 22:06:12 +00:00
|
|
|
| 'showContactDetail'
|
|
|
|
| 'showContactModal'
|
|
|
|
| 'showExpiredIncomingTapToViewToast'
|
|
|
|
| 'showExpiredOutgoingTapToViewToast'
|
2021-04-27 22:35:35 +00:00
|
|
|
| 'showForwardMessageModal'
|
2021-07-20 19:56:50 +00:00
|
|
|
| 'showSafetyNumber'
|
2021-03-24 22:06:12 +00:00
|
|
|
| 'showVisualAttachment'
|
|
|
|
>;
|
|
|
|
|
|
|
|
const mapStateToProps = (
|
|
|
|
state: StateType,
|
|
|
|
props: OwnProps
|
|
|
|
): MessageDetailProps => {
|
|
|
|
const {
|
|
|
|
contacts,
|
|
|
|
errors,
|
|
|
|
message,
|
|
|
|
receivedAt,
|
|
|
|
sentAt,
|
|
|
|
|
2021-06-16 00:44:14 +00:00
|
|
|
sendAnyway,
|
|
|
|
showSafetyNumber,
|
|
|
|
|
2021-06-17 17:15:10 +00:00
|
|
|
checkForAccount,
|
2021-03-24 22:06:12 +00:00
|
|
|
clearSelectedMessage,
|
|
|
|
deleteMessage,
|
|
|
|
deleteMessageForEveryone,
|
|
|
|
displayTapToViewMessage,
|
|
|
|
downloadAttachment,
|
2021-06-17 17:15:10 +00:00
|
|
|
doubleCheckMissingQuoteReference,
|
2021-03-24 22:06:12 +00:00
|
|
|
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-06-16 00:44:14 +00:00
|
|
|
sendAnyway,
|
|
|
|
showSafetyNumber,
|
|
|
|
|
2021-06-17 17:15:10 +00:00
|
|
|
checkForAccount,
|
2021-03-24 22:06:12 +00:00
|
|
|
clearSelectedMessage,
|
|
|
|
deleteMessage,
|
|
|
|
deleteMessageForEveryone,
|
|
|
|
displayTapToViewMessage,
|
|
|
|
downloadAttachment,
|
2021-06-17 17:15:10 +00:00
|
|
|
doubleCheckMissingQuoteReference,
|
2021-03-24 22:06:12 +00:00
|
|
|
kickOffAttachmentDownload,
|
|
|
|
markAttachmentAsCorrupted,
|
2021-08-12 18:15:55 +00:00
|
|
|
markViewed,
|
2021-03-24 22:06:12 +00:00
|
|
|
openConversation,
|
|
|
|
openLink,
|
|
|
|
reactToMessage,
|
|
|
|
renderAudioAttachment,
|
|
|
|
renderEmojiPicker,
|
|
|
|
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);
|