2021-10-05 16:47:06 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { CompositionAreaPropsType } from './CompositionArea';
|
|
|
|
import type { OwnProps as ConversationHeaderPropsType } from './ConversationHeader';
|
2022-12-14 18:41:04 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { TimelinePropsType } from './Timeline';
|
2022-12-14 18:41:04 +00:00
|
|
|
import * as log from '../../logging/log';
|
|
|
|
import { ConversationView } from '../../components/conversation/ConversationView';
|
|
|
|
import { PanelType } from '../../types/Panels';
|
|
|
|
import { SmartChatColorPicker } from './ChatColorPicker';
|
|
|
|
import { SmartCompositionArea } from './CompositionArea';
|
|
|
|
import { SmartConversationHeader } from './ConversationHeader';
|
2021-10-26 19:15:33 +00:00
|
|
|
import { SmartTimeline } from './Timeline';
|
2022-12-14 18:41:04 +00:00
|
|
|
import { getTopPanelRenderableByReact } from '../selectors/conversations';
|
|
|
|
import { mapDispatchToProps } from '../actions';
|
2021-10-05 16:47:06 +00:00
|
|
|
|
|
|
|
export type PropsType = {
|
2022-12-08 01:26:59 +00:00
|
|
|
conversationId: string;
|
2021-10-05 16:47:06 +00:00
|
|
|
compositionAreaProps: Pick<
|
|
|
|
CompositionAreaPropsType,
|
|
|
|
| 'id'
|
|
|
|
| 'onCancelJoinRequest'
|
|
|
|
| 'onClearAttachments'
|
|
|
|
| 'onClickAddPack'
|
|
|
|
| 'onCloseLinkPreview'
|
|
|
|
| 'onEditorStateChange'
|
|
|
|
| 'onSelectMediaQuality'
|
|
|
|
| 'onTextTooLong'
|
|
|
|
>;
|
|
|
|
conversationHeaderProps: ConversationHeaderPropsType;
|
|
|
|
timelineProps: TimelinePropsType;
|
|
|
|
};
|
|
|
|
|
2022-12-14 18:41:04 +00:00
|
|
|
const mapStateToProps = (state: StateType, props: PropsType) => {
|
2022-12-08 01:26:59 +00:00
|
|
|
const {
|
|
|
|
compositionAreaProps,
|
|
|
|
conversationHeaderProps,
|
|
|
|
conversationId,
|
|
|
|
timelineProps,
|
|
|
|
} = props;
|
2021-10-05 16:47:06 +00:00
|
|
|
|
2022-12-14 18:41:04 +00:00
|
|
|
const topPanel = getTopPanelRenderableByReact(state);
|
|
|
|
|
2021-10-05 16:47:06 +00:00
|
|
|
return {
|
2022-12-08 01:26:59 +00:00
|
|
|
conversationId,
|
2021-10-05 16:47:06 +00:00
|
|
|
renderCompositionArea: () => (
|
|
|
|
<SmartCompositionArea {...compositionAreaProps} />
|
|
|
|
),
|
|
|
|
renderConversationHeader: () => (
|
|
|
|
<SmartConversationHeader {...conversationHeaderProps} />
|
|
|
|
),
|
|
|
|
renderTimeline: () => <SmartTimeline {...timelineProps} />,
|
2022-12-14 18:41:04 +00:00
|
|
|
renderPanel: () => {
|
|
|
|
if (!topPanel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topPanel.type === PanelType.ChatColorEditor) {
|
|
|
|
return (
|
|
|
|
<div className="panel">
|
|
|
|
<SmartChatColorPicker conversationId={conversationId} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const unknownPanelType: never = topPanel.type;
|
|
|
|
log.warn(`renderPanel: Got unexpected panel type ${unknownPanelType}`);
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
},
|
2021-10-05 16:47:06 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartConversationView = smart(ConversationView);
|