2022-12-15 01:10:09 +00:00
|
|
|
// Copyright 2021-2022 Signal Messenger, LLC
|
2021-10-05 16:47:06 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
2022-12-15 01:10:09 +00:00
|
|
|
import { useSelector } 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';
|
2022-12-15 01:10:09 +00:00
|
|
|
import type { ReactPanelRenderType } from '../../types/Panels';
|
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';
|
2022-12-15 01:10:09 +00:00
|
|
|
import { ContactDetail } from '../../components/conversation/ContactDetail';
|
2022-12-14 18:41:04 +00:00
|
|
|
import { ConversationView } from '../../components/conversation/ConversationView';
|
|
|
|
import { PanelType } from '../../types/Panels';
|
2022-12-20 17:50:23 +00:00
|
|
|
import { SmartAllMedia } from './AllMedia';
|
2022-12-14 18:41:04 +00:00
|
|
|
import { SmartChatColorPicker } from './ChatColorPicker';
|
|
|
|
import { SmartCompositionArea } from './CompositionArea';
|
2022-12-16 03:12:05 +00:00
|
|
|
import { SmartConversationDetails } from './ConversationDetails';
|
2022-12-14 18:41:04 +00:00
|
|
|
import { SmartConversationHeader } from './ConversationHeader';
|
2022-12-16 03:12:05 +00:00
|
|
|
import { SmartConversationNotificationsSettings } from './ConversationNotificationsSettings';
|
|
|
|
import { SmartGV1Members } from './GV1Members';
|
2022-12-15 01:10:09 +00:00
|
|
|
import { SmartGroupLinkManagement } from './GroupLinkManagement';
|
|
|
|
import { SmartGroupV2Permissions } from './GroupV2Permissions';
|
|
|
|
import { SmartPendingInvites } from './PendingInvites';
|
|
|
|
import { SmartStickerManager } from './StickerManager';
|
2021-10-26 19:15:33 +00:00
|
|
|
import { SmartTimeline } from './Timeline';
|
2022-12-15 01:10:09 +00:00
|
|
|
import { getIntl } from '../selectors/user';
|
2022-12-14 18:41:04 +00:00
|
|
|
import { getTopPanelRenderableByReact } from '../selectors/conversations';
|
2022-12-15 01:10:09 +00:00
|
|
|
import { startConversation } from '../../util/startConversation';
|
|
|
|
import { useComposerActions } from '../ducks/composer';
|
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'
|
|
|
|
| 'onCloseLinkPreview'
|
|
|
|
| 'onEditorStateChange'
|
|
|
|
| 'onSelectMediaQuality'
|
|
|
|
| 'onTextTooLong'
|
|
|
|
>;
|
|
|
|
conversationHeaderProps: ConversationHeaderPropsType;
|
|
|
|
timelineProps: TimelinePropsType;
|
|
|
|
};
|
|
|
|
|
2022-12-15 01:10:09 +00:00
|
|
|
export function SmartConversationView({
|
|
|
|
compositionAreaProps,
|
|
|
|
conversationHeaderProps,
|
|
|
|
conversationId,
|
|
|
|
timelineProps,
|
|
|
|
}: PropsType): JSX.Element {
|
|
|
|
const topPanel = useSelector<StateType, ReactPanelRenderType | undefined>(
|
|
|
|
getTopPanelRenderableByReact
|
|
|
|
);
|
|
|
|
|
|
|
|
const { processAttachments } = useComposerActions();
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ConversationView
|
|
|
|
conversationId={conversationId}
|
|
|
|
processAttachments={processAttachments}
|
|
|
|
renderCompositionArea={() => (
|
|
|
|
<SmartCompositionArea {...compositionAreaProps} />
|
|
|
|
)}
|
|
|
|
renderConversationHeader={() => (
|
|
|
|
<SmartConversationHeader {...conversationHeaderProps} />
|
|
|
|
)}
|
|
|
|
renderTimeline={() => <SmartTimeline {...timelineProps} />}
|
|
|
|
renderPanel={() => {
|
|
|
|
if (!topPanel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-20 17:50:23 +00:00
|
|
|
if (topPanel.type === PanelType.AllMedia) {
|
|
|
|
return (
|
|
|
|
<div className="panel">
|
|
|
|
<SmartAllMedia conversationId={conversationId} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-15 01:10:09 +00:00
|
|
|
if (topPanel.type === PanelType.ChatColorEditor) {
|
|
|
|
return (
|
|
|
|
<div className="panel">
|
|
|
|
<SmartChatColorPicker conversationId={conversationId} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topPanel.type === PanelType.ContactDetails) {
|
|
|
|
const { contact, signalAccount } = topPanel.args;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="panel">
|
|
|
|
<ContactDetail
|
|
|
|
contact={contact}
|
|
|
|
hasSignalAccount={Boolean(signalAccount)}
|
|
|
|
i18n={i18n}
|
|
|
|
onSendMessage={() => {
|
|
|
|
if (signalAccount) {
|
|
|
|
startConversation(
|
|
|
|
signalAccount.phoneNumber,
|
|
|
|
signalAccount.uuid
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-16 03:12:05 +00:00
|
|
|
if (topPanel.type === PanelType.ConversationDetails) {
|
|
|
|
return (
|
|
|
|
<div className="panel conversation-details-pane">
|
|
|
|
<SmartConversationDetails conversationId={conversationId} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-15 01:10:09 +00:00
|
|
|
if (topPanel.type === PanelType.GroupInvites) {
|
|
|
|
return (
|
|
|
|
<div className="panel">
|
|
|
|
<SmartPendingInvites
|
|
|
|
conversationId={conversationId}
|
|
|
|
ourUuid={window.storage.user.getCheckedUuid().toString()}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topPanel.type === PanelType.GroupLinkManagement) {
|
|
|
|
return (
|
|
|
|
<div className="panel">
|
|
|
|
<SmartGroupLinkManagement conversationId={conversationId} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topPanel.type === PanelType.GroupPermissions) {
|
|
|
|
return (
|
|
|
|
<div className="panel">
|
|
|
|
<SmartGroupV2Permissions conversationId={conversationId} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topPanel.type === PanelType.GroupV1Members) {
|
|
|
|
return (
|
|
|
|
<div className="group-member-list panel">
|
|
|
|
<SmartGV1Members conversationId={conversationId} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topPanel.type === PanelType.NotificationSettings) {
|
|
|
|
return (
|
|
|
|
<div className="panel">
|
|
|
|
<SmartConversationNotificationsSettings
|
|
|
|
conversationId={conversationId}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (topPanel.type === PanelType.StickerManager) {
|
|
|
|
return (
|
|
|
|
<div className="panel sticker-manager-wrapper">
|
|
|
|
<SmartStickerManager />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2021-10-05 16:47:06 +00:00
|
|
|
|
2022-12-15 01:10:09 +00:00
|
|
|
log.warn('renderPanel: Got unexpected panel', topPanel);
|
2021-10-05 16:47:06 +00:00
|
|
|
|
2022-12-15 01:10:09 +00:00
|
|
|
return undefined;
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|