2021-04-27 22:35:35 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { mapDispatchToProps } from '../actions';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { DataPropsType } from '../../components/ForwardMessageModal';
|
|
|
|
import { ForwardMessageModal } from '../../components/ForwardMessageModal';
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import type { BodyRangeType } from '../../types/Util';
|
|
|
|
import type { LinkPreviewType } from '../../types/message/LinkPreviews';
|
2021-04-27 22:35:35 +00:00
|
|
|
import { getAllComposableConversations } from '../selectors/conversations';
|
|
|
|
import { getLinkPreview } from '../selectors/linkPreviews';
|
|
|
|
import { getIntl } from '../selectors/user';
|
2021-09-09 16:29:01 +00:00
|
|
|
import { getEmojiSkinTone } from '../selectors/items';
|
2021-04-27 22:35:35 +00:00
|
|
|
import { selectRecentEmojis } from '../selectors/emojis';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { AttachmentType } from '../../types/Attachment';
|
2021-04-27 22:35:35 +00:00
|
|
|
|
|
|
|
export type SmartForwardMessageModalProps = {
|
|
|
|
attachments?: Array<AttachmentType>;
|
|
|
|
doForwardMessage: (
|
|
|
|
selectedContacts: Array<string>,
|
|
|
|
messageBody?: string,
|
|
|
|
attachments?: Array<AttachmentType>,
|
|
|
|
linkPreview?: LinkPreviewType
|
|
|
|
) => void;
|
|
|
|
isSticker: boolean;
|
|
|
|
messageBody?: string;
|
|
|
|
onClose: () => void;
|
|
|
|
onEditorStateChange: (
|
|
|
|
messageText: string,
|
|
|
|
bodyRanges: Array<BodyRangeType>,
|
|
|
|
caretLocation?: number
|
|
|
|
) => unknown;
|
|
|
|
onTextTooLong: () => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (
|
|
|
|
state: StateType,
|
|
|
|
props: SmartForwardMessageModalProps
|
|
|
|
): DataPropsType => {
|
|
|
|
const {
|
|
|
|
attachments,
|
|
|
|
doForwardMessage,
|
|
|
|
isSticker,
|
|
|
|
messageBody,
|
|
|
|
onClose,
|
|
|
|
onEditorStateChange,
|
|
|
|
onTextTooLong,
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const candidateConversations = getAllComposableConversations(state);
|
|
|
|
const recentEmojis = selectRecentEmojis(state);
|
2021-09-09 16:29:01 +00:00
|
|
|
const skinTone = getEmojiSkinTone(state);
|
2021-04-27 22:35:35 +00:00
|
|
|
const linkPreview = getLinkPreview(state);
|
|
|
|
|
|
|
|
return {
|
|
|
|
attachments,
|
|
|
|
candidateConversations,
|
|
|
|
doForwardMessage,
|
|
|
|
i18n: getIntl(state),
|
|
|
|
isSticker,
|
|
|
|
linkPreview,
|
|
|
|
messageBody,
|
|
|
|
onClose,
|
|
|
|
onEditorStateChange,
|
|
|
|
recentEmojis,
|
|
|
|
skinTone,
|
|
|
|
onTextTooLong,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, {
|
|
|
|
...mapDispatchToProps,
|
|
|
|
onPickEmoji: mapDispatchToProps.onUseEmoji,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const SmartForwardMessageModal = smart(ForwardMessageModal);
|