2021-05-28 16:15:17 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-12-22 03:07:45 +00:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
|
|
import type { GlobalModalsStateType } from '../ducks/globalModals';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2022-12-22 03:07:45 +00:00
|
|
|
import { ErrorModal } from '../../components/ErrorModal';
|
2022-08-16 23:59:11 +00:00
|
|
|
import { GlobalModalContainer } from '../../components/GlobalModalContainer';
|
2022-12-22 03:07:45 +00:00
|
|
|
import { SmartAddUserToAnotherGroupModal } from './AddUserToAnotherGroupModal';
|
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-12-22 03:07:45 +00:00
|
|
|
import { SmartShortcutGuideModal } from './ShortcutGuideModal';
|
|
|
|
import { SmartStickerPreviewModal } from './StickerPreviewModal';
|
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';
|
2022-09-26 16:24:52 +00:00
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
2022-12-22 03:07:45 +00:00
|
|
|
import { useGlobalModalActions } from '../ducks/globalModals';
|
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 />;
|
|
|
|
}
|
|
|
|
|
2022-12-22 03:07:45 +00:00
|
|
|
function renderShortcutGuideModal(): JSX.Element {
|
|
|
|
return <SmartShortcutGuideModal />;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function SmartGlobalModalContainer(): JSX.Element {
|
|
|
|
const conversationsStoppingSend = useSelector(getConversationsStoppingSend);
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const theme = useSelector(getTheme);
|
|
|
|
|
|
|
|
const hasSafetyNumberChangeModal = conversationsStoppingSend.length > 0;
|
|
|
|
|
|
|
|
const {
|
|
|
|
addUserToAnotherGroupModalContactId,
|
|
|
|
isProfileEditorVisible,
|
|
|
|
isSignalConnectionsVisible,
|
|
|
|
isShortcutGuideModalVisible,
|
|
|
|
isStoriesSettingsVisible,
|
|
|
|
isWhatsNewVisible,
|
|
|
|
safetyNumberModalContactId,
|
|
|
|
stickerPackPreviewId,
|
|
|
|
} = useSelector<StateType, GlobalModalsStateType>(
|
|
|
|
state => state.globalModals
|
|
|
|
);
|
|
|
|
|
|
|
|
const {
|
|
|
|
closeErrorModal,
|
|
|
|
hideWhatsNewModal,
|
|
|
|
hideUserNotFoundModal,
|
|
|
|
toggleSignalConnectionsModal,
|
|
|
|
} = useGlobalModalActions();
|
|
|
|
|
|
|
|
const renderAddUserToAnotherGroup = useCallback(() => {
|
|
|
|
return (
|
|
|
|
<SmartAddUserToAnotherGroupModal
|
|
|
|
contactID={String(addUserToAnotherGroupModalContactId)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}, [addUserToAnotherGroupModalContactId]);
|
|
|
|
|
|
|
|
const renderSafetyNumber = useCallback(
|
|
|
|
() => (
|
|
|
|
<SmartSafetyNumberModal contactID={String(safetyNumberModalContactId)} />
|
|
|
|
),
|
|
|
|
[safetyNumberModalContactId]
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderStickerPreviewModal = useCallback(
|
|
|
|
() =>
|
2022-12-09 19:01:46 +00:00
|
|
|
stickerPackPreviewId ? (
|
|
|
|
<SmartStickerPreviewModal packId={stickerPackPreviewId} />
|
|
|
|
) : null,
|
2022-12-22 03:07:45 +00:00
|
|
|
[stickerPackPreviewId]
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderErrorModal = useCallback(
|
|
|
|
({ description, title }: { description?: string; title?: string }) => (
|
|
|
|
<ErrorModal
|
|
|
|
title={title}
|
|
|
|
description={description}
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={closeErrorModal}
|
2021-10-06 20:27:14 +00:00
|
|
|
/>
|
|
|
|
),
|
2022-12-22 03:07:45 +00:00
|
|
|
[closeErrorModal, i18n]
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<GlobalModalContainer
|
|
|
|
hasSafetyNumberChangeModal={hasSafetyNumberChangeModal}
|
|
|
|
hideUserNotFoundModal={hideUserNotFoundModal}
|
|
|
|
hideWhatsNewModal={hideWhatsNewModal}
|
|
|
|
i18n={i18n}
|
|
|
|
isProfileEditorVisible={isProfileEditorVisible}
|
|
|
|
isShortcutGuideModalVisible={isShortcutGuideModalVisible}
|
|
|
|
isSignalConnectionsVisible={isSignalConnectionsVisible}
|
|
|
|
isStoriesSettingsVisible={isStoriesSettingsVisible}
|
|
|
|
isWhatsNewVisible={isWhatsNewVisible}
|
|
|
|
renderAddUserToAnotherGroup={renderAddUserToAnotherGroup}
|
|
|
|
renderContactModal={renderContactModal}
|
|
|
|
renderErrorModal={renderErrorModal}
|
|
|
|
renderForwardMessageModal={renderForwardMessageModal}
|
|
|
|
renderProfileEditor={renderProfileEditor}
|
|
|
|
renderSafetyNumber={renderSafetyNumber}
|
|
|
|
renderSendAnywayDialog={renderSendAnywayDialog}
|
|
|
|
renderShortcutGuideModal={renderShortcutGuideModal}
|
|
|
|
renderStickerPreviewModal={renderStickerPreviewModal}
|
|
|
|
renderStoriesSettings={renderStoriesSettings}
|
|
|
|
theme={theme}
|
|
|
|
toggleSignalConnectionsModal={toggleSignalConnectionsModal}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|