2021-05-28 16:15:17 +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 { StateType } from '../reducer';
|
2022-08-16 23:59:11 +00:00
|
|
|
import { GlobalModalContainer } from '../../components/GlobalModalContainer';
|
2021-09-21 22:37:10 +00:00
|
|
|
import { SmartContactModal } from './ContactModal';
|
2022-07-01 00:52:03 +00:00
|
|
|
import { SmartForwardMessageModal } from './ForwardMessageModal';
|
|
|
|
import { SmartProfileEditorModal } from './ProfileEditorModal';
|
2021-10-06 20:27:14 +00:00
|
|
|
import { SmartSafetyNumberModal } from './SafetyNumberModal';
|
2022-08-16 23:59:11 +00:00
|
|
|
import { SmartSendAnywayDialog } from './SendAnywayDialog';
|
2022-07-21 00:07:09 +00:00
|
|
|
import { SmartStoriesSettingsModal } from './StoriesSettingsModal';
|
2022-08-16 23:59:11 +00:00
|
|
|
import { getConversationsStoppingSend } from '../selectors/conversations';
|
|
|
|
import { mapDispatchToProps } from '../actions';
|
2021-07-19 19:26:06 +00:00
|
|
|
|
2022-09-26 16:24:52 +00:00
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
|
|
|
import { SmartAddUserToAnotherGroupModal } from './AddUserToAnotherGroupModal';
|
2022-12-09 19:01:46 +00:00
|
|
|
import { SmartStickerPreviewModal } from './StickerPreviewModal';
|
2021-10-23 00:41:45 +00:00
|
|
|
|
2021-07-19 19:26:06 +00:00
|
|
|
function renderProfileEditor(): JSX.Element {
|
2021-11-01 19:13:35 +00:00
|
|
|
return <SmartProfileEditorModal />;
|
2021-07-19 19:26:06 +00:00
|
|
|
}
|
|
|
|
|
2021-09-21 22:37:10 +00:00
|
|
|
function renderContactModal(): JSX.Element {
|
|
|
|
return <SmartContactModal />;
|
|
|
|
}
|
|
|
|
|
2022-07-01 00:52:03 +00:00
|
|
|
function renderForwardMessageModal(): JSX.Element {
|
|
|
|
return <SmartForwardMessageModal />;
|
|
|
|
}
|
|
|
|
|
2022-07-21 00:07:09 +00:00
|
|
|
function renderStoriesSettings(): JSX.Element {
|
|
|
|
return <SmartStoriesSettingsModal />;
|
|
|
|
}
|
|
|
|
|
2022-08-16 23:59:11 +00:00
|
|
|
function renderSendAnywayDialog(): JSX.Element {
|
|
|
|
return <SmartSendAnywayDialog />;
|
|
|
|
}
|
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
const mapStateToProps = (state: StateType) => {
|
2021-10-23 00:41:45 +00:00
|
|
|
const i18n = getIntl(state);
|
|
|
|
|
2022-12-09 19:01:46 +00:00
|
|
|
const { stickerPackPreviewId } = state.globalModals;
|
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
return {
|
|
|
|
...state.globalModals,
|
2022-08-16 23:59:11 +00:00
|
|
|
hasSafetyNumberChangeModal: getConversationsStoppingSend(state).length > 0,
|
2021-10-23 00:41:45 +00:00
|
|
|
i18n,
|
2022-09-26 16:24:52 +00:00
|
|
|
theme: getTheme(state),
|
2021-09-21 22:37:10 +00:00
|
|
|
renderContactModal,
|
2022-07-01 00:52:03 +00:00
|
|
|
renderForwardMessageModal,
|
2021-07-19 19:26:06 +00:00
|
|
|
renderProfileEditor,
|
2022-07-21 00:07:09 +00:00
|
|
|
renderStoriesSettings,
|
2022-12-09 19:01:46 +00:00
|
|
|
renderStickerPreviewModal: () =>
|
|
|
|
stickerPackPreviewId ? (
|
|
|
|
<SmartStickerPreviewModal packId={stickerPackPreviewId} />
|
|
|
|
) : null,
|
2021-10-06 20:27:14 +00:00
|
|
|
renderSafetyNumber: () => (
|
|
|
|
<SmartSafetyNumberModal
|
|
|
|
contactID={String(state.globalModals.safetyNumberModalContactId)}
|
|
|
|
/>
|
|
|
|
),
|
2022-09-26 16:24:52 +00:00
|
|
|
renderAddUserToAnotherGroup: () => {
|
|
|
|
return (
|
|
|
|
<SmartAddUserToAnotherGroupModal
|
|
|
|
contactID={String(
|
|
|
|
state.globalModals.addUserToAnotherGroupModalContactId
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
2022-08-16 23:59:11 +00:00
|
|
|
renderSendAnywayDialog,
|
2021-05-28 16:15:17 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartGlobalModalContainer = smart(GlobalModalContainer);
|