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-16 15:53:41 +00:00
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
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';
|
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-11-16 15:53:41 +00:00
|
|
|
| 'getPreferredBadge'
|
2021-09-10 18:00:31 +00:00
|
|
|
| 'i18n'
|
|
|
|
| 'interactionMode'
|
|
|
|
| 'renderAudioAttachment'
|
|
|
|
| 'renderEmojiPicker'
|
|
|
|
| 'renderReactionPicker'
|
2021-11-15 22:53:42 +00:00
|
|
|
| 'theme'
|
2022-12-09 06:08:55 +00:00
|
|
|
| 'showContactModal'
|
2022-12-14 19:05:32 +00:00
|
|
|
| 'showConversation'
|
2021-03-24 22:06:12 +00:00
|
|
|
>;
|
|
|
|
|
|
|
|
const mapStateToProps = (
|
|
|
|
state: StateType,
|
|
|
|
props: OwnProps
|
|
|
|
): MessageDetailProps => {
|
|
|
|
const {
|
|
|
|
contacts,
|
|
|
|
errors,
|
|
|
|
message,
|
|
|
|
receivedAt,
|
|
|
|
sentAt,
|
|
|
|
|
2022-04-12 00:26:09 +00:00
|
|
|
startConversation,
|
2021-03-24 22:06:12 +00:00
|
|
|
} = props;
|
|
|
|
|
2021-06-07 16:50:18 +00:00
|
|
|
const contactNameColor =
|
|
|
|
message.conversationType === 'group'
|
|
|
|
? getContactNameColorSelector(state)(
|
|
|
|
message.conversationId,
|
|
|
|
message.author.id
|
|
|
|
)
|
|
|
|
: undefined;
|
|
|
|
|
2021-11-16 15:53:41 +00:00
|
|
|
const getPreferredBadge = getPreferredBadgeSelector(state);
|
|
|
|
|
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,
|
|
|
|
|
2021-11-16 15:53:41 +00:00
|
|
|
getPreferredBadge,
|
2021-03-24 22:06:12 +00:00
|
|
|
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
|
|
|
|
|
|
|
renderAudioAttachment,
|
2022-04-12 00:26:09 +00:00
|
|
|
startConversation,
|
2021-03-24 22:06:12 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
export const SmartMessageDetail = smart(MessageDetail);
|