2021-05-28 16:15:17 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo, useCallback } from 'react';
|
2022-12-22 03:07:45 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
2024-02-22 21:19:50 +00:00
|
|
|
import type { ButtonVariant } from '../../components/Button';
|
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';
|
2024-02-16 22:16:13 +00:00
|
|
|
import { SmartAboutContactModal } from './AboutContactModal';
|
2022-12-22 03:07:45 +00:00
|
|
|
import { SmartAddUserToAnotherGroupModal } from './AddUserToAnotherGroupModal';
|
2021-09-21 22:37:10 +00:00
|
|
|
import { SmartContactModal } from './ContactModal';
|
2023-03-27 23:48:57 +00:00
|
|
|
import { SmartEditHistoryMessagesModal } from './EditHistoryMessagesModal';
|
2023-03-20 22:23:53 +00:00
|
|
|
import { SmartForwardMessagesModal } from './ForwardMessagesModal';
|
2022-07-01 00:52:03 +00:00
|
|
|
import { SmartProfileEditorModal } from './ProfileEditorModal';
|
2024-01-29 20:09:54 +00:00
|
|
|
import { SmartUsernameOnboardingModal } from './UsernameOnboardingModal';
|
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';
|
2024-02-16 22:16:13 +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';
|
2023-04-10 21:38:34 +00:00
|
|
|
import { SmartDeleteMessagesModal } from './DeleteMessagesModal';
|
2024-03-12 16:29:31 +00:00
|
|
|
import { SmartMessageRequestActionsConfirmation } from './MessageRequestActionsConfirmation';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { getGlobalModalsState } from '../selectors/globalModals';
|
2024-03-26 19:48:33 +00:00
|
|
|
import { SmartEditNicknameAndNoteModal } from './EditNicknameAndNoteModal';
|
|
|
|
import { SmartNotePreviewModal } from './NotePreviewModal';
|
2024-06-10 15:23:43 +00:00
|
|
|
import { SmartCallLinkEditModal } from './CallLinkEditModal';
|
|
|
|
|
|
|
|
function renderCallLinkEditModal(): JSX.Element {
|
|
|
|
return <SmartCallLinkEditModal />;
|
|
|
|
}
|
2021-10-23 00:41:45 +00:00
|
|
|
|
2023-03-27 23:48:57 +00:00
|
|
|
function renderEditHistoryMessagesModal(): JSX.Element {
|
|
|
|
return <SmartEditHistoryMessagesModal />;
|
|
|
|
}
|
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
function renderEditNicknameAndNoteModal(): JSX.Element {
|
|
|
|
return <SmartEditNicknameAndNoteModal />;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-01-29 20:09:54 +00:00
|
|
|
function renderUsernameOnboarding(): JSX.Element {
|
|
|
|
return <SmartUsernameOnboardingModal />;
|
|
|
|
}
|
|
|
|
|
2021-09-21 22:37:10 +00:00
|
|
|
function renderContactModal(): JSX.Element {
|
|
|
|
return <SmartContactModal />;
|
|
|
|
}
|
|
|
|
|
2023-04-10 21:38:34 +00:00
|
|
|
function renderDeleteMessagesModal(): JSX.Element {
|
|
|
|
return <SmartDeleteMessagesModal />;
|
|
|
|
}
|
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
function renderForwardMessagesModal(): JSX.Element {
|
|
|
|
return <SmartForwardMessagesModal />;
|
2022-07-01 00:52:03 +00:00
|
|
|
}
|
|
|
|
|
2024-03-12 16:29:31 +00:00
|
|
|
function renderMessageRequestActionsConfirmation(): JSX.Element {
|
|
|
|
return <SmartMessageRequestActionsConfirmation />;
|
|
|
|
}
|
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
function renderNotePreviewModal(): JSX.Element {
|
|
|
|
return <SmartNotePreviewModal />;
|
|
|
|
}
|
|
|
|
|
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 />;
|
|
|
|
}
|
|
|
|
|
2024-02-16 22:16:13 +00:00
|
|
|
function renderAboutContactModal(): JSX.Element {
|
|
|
|
return <SmartAboutContactModal />;
|
|
|
|
}
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartGlobalModalContainer = memo(
|
|
|
|
function SmartGlobalModalContainer() {
|
|
|
|
const conversationsStoppingSend = useSelector(getConversationsStoppingSend);
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const theme = useSelector(getTheme);
|
|
|
|
|
|
|
|
const hasSafetyNumberChangeModal = conversationsStoppingSend.length > 0;
|
|
|
|
|
|
|
|
const {
|
|
|
|
aboutContactModalContactId,
|
|
|
|
addUserToAnotherGroupModalContactId,
|
2024-06-10 15:23:43 +00:00
|
|
|
callLinkEditModalRoomId,
|
2024-03-13 20:44:13 +00:00
|
|
|
contactModalState,
|
|
|
|
deleteMessagesProps,
|
|
|
|
editHistoryMessages,
|
2024-03-26 19:48:33 +00:00
|
|
|
editNicknameAndNoteModalProps,
|
2024-03-13 20:44:13 +00:00
|
|
|
errorModalProps,
|
|
|
|
forwardMessagesProps,
|
|
|
|
messageRequestActionsConfirmationProps,
|
2024-03-26 19:48:33 +00:00
|
|
|
notePreviewModalProps,
|
2024-03-13 20:44:13 +00:00
|
|
|
isProfileEditorVisible,
|
|
|
|
isShortcutGuideModalVisible,
|
|
|
|
isSignalConnectionsVisible,
|
|
|
|
isStoriesSettingsVisible,
|
|
|
|
isWhatsNewVisible,
|
|
|
|
usernameOnboardingState,
|
|
|
|
safetyNumberChangedBlockingData,
|
|
|
|
safetyNumberModalContactId,
|
|
|
|
stickerPackPreviewId,
|
|
|
|
userNotFoundModalState,
|
|
|
|
} = useSelector(getGlobalModalsState);
|
|
|
|
|
|
|
|
const {
|
|
|
|
closeErrorModal,
|
|
|
|
hideUserNotFoundModal,
|
|
|
|
hideWhatsNewModal,
|
|
|
|
toggleSignalConnectionsModal,
|
|
|
|
} = useGlobalModalActions();
|
|
|
|
|
|
|
|
const renderAddUserToAnotherGroup = useCallback(() => {
|
|
|
|
return (
|
|
|
|
<SmartAddUserToAnotherGroupModal
|
|
|
|
contactID={String(addUserToAnotherGroupModalContactId)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}, [addUserToAnotherGroupModalContactId]);
|
|
|
|
|
|
|
|
const renderSafetyNumber = useCallback(
|
|
|
|
() => (
|
|
|
|
<SmartSafetyNumberModal
|
|
|
|
contactID={String(safetyNumberModalContactId)}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
[safetyNumberModalContactId]
|
2022-12-22 03:07:45 +00:00
|
|
|
);
|
2024-03-13 20:44:13 +00:00
|
|
|
|
|
|
|
const renderStickerPreviewModal = useCallback(
|
|
|
|
() =>
|
|
|
|
stickerPackPreviewId ? (
|
|
|
|
<SmartStickerPreviewModal packId={stickerPackPreviewId} />
|
|
|
|
) : null,
|
|
|
|
[stickerPackPreviewId]
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderErrorModal = useCallback(
|
|
|
|
({
|
|
|
|
buttonVariant,
|
|
|
|
description,
|
|
|
|
title,
|
|
|
|
}: {
|
|
|
|
buttonVariant?: ButtonVariant;
|
|
|
|
description?: string;
|
|
|
|
title?: string;
|
|
|
|
}) => (
|
|
|
|
<ErrorModal
|
|
|
|
buttonVariant={buttonVariant}
|
|
|
|
description={description}
|
|
|
|
title={title}
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={closeErrorModal}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
[closeErrorModal, i18n]
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<GlobalModalContainer
|
|
|
|
addUserToAnotherGroupModalContactId={
|
|
|
|
addUserToAnotherGroupModalContactId
|
|
|
|
}
|
2024-06-10 15:23:43 +00:00
|
|
|
callLinkEditModalRoomId={callLinkEditModalRoomId}
|
2024-03-13 20:44:13 +00:00
|
|
|
contactModalState={contactModalState}
|
|
|
|
editHistoryMessages={editHistoryMessages}
|
2024-03-26 19:48:33 +00:00
|
|
|
editNicknameAndNoteModalProps={editNicknameAndNoteModalProps}
|
2024-03-13 20:44:13 +00:00
|
|
|
errorModalProps={errorModalProps}
|
|
|
|
deleteMessagesProps={deleteMessagesProps}
|
|
|
|
forwardMessagesProps={forwardMessagesProps}
|
|
|
|
messageRequestActionsConfirmationProps={
|
|
|
|
messageRequestActionsConfirmationProps
|
|
|
|
}
|
2024-03-26 19:48:33 +00:00
|
|
|
notePreviewModalProps={notePreviewModalProps}
|
2024-03-13 20:44:13 +00:00
|
|
|
hasSafetyNumberChangeModal={hasSafetyNumberChangeModal}
|
|
|
|
hideUserNotFoundModal={hideUserNotFoundModal}
|
|
|
|
hideWhatsNewModal={hideWhatsNewModal}
|
2022-12-22 03:07:45 +00:00
|
|
|
i18n={i18n}
|
2024-03-13 20:44:13 +00:00
|
|
|
isAboutContactModalVisible={aboutContactModalContactId != null}
|
|
|
|
isProfileEditorVisible={isProfileEditorVisible}
|
|
|
|
isShortcutGuideModalVisible={isShortcutGuideModalVisible}
|
|
|
|
isSignalConnectionsVisible={isSignalConnectionsVisible}
|
|
|
|
isStoriesSettingsVisible={isStoriesSettingsVisible}
|
|
|
|
isWhatsNewVisible={isWhatsNewVisible}
|
|
|
|
renderAboutContactModal={renderAboutContactModal}
|
|
|
|
renderAddUserToAnotherGroup={renderAddUserToAnotherGroup}
|
2024-06-10 15:23:43 +00:00
|
|
|
renderCallLinkEditModal={renderCallLinkEditModal}
|
2024-03-13 20:44:13 +00:00
|
|
|
renderContactModal={renderContactModal}
|
|
|
|
renderEditHistoryMessagesModal={renderEditHistoryMessagesModal}
|
2024-03-26 19:48:33 +00:00
|
|
|
renderEditNicknameAndNoteModal={renderEditNicknameAndNoteModal}
|
2024-03-13 20:44:13 +00:00
|
|
|
renderErrorModal={renderErrorModal}
|
|
|
|
renderDeleteMessagesModal={renderDeleteMessagesModal}
|
|
|
|
renderForwardMessagesModal={renderForwardMessagesModal}
|
|
|
|
renderMessageRequestActionsConfirmation={
|
|
|
|
renderMessageRequestActionsConfirmation
|
|
|
|
}
|
2024-03-26 19:48:33 +00:00
|
|
|
renderNotePreviewModal={renderNotePreviewModal}
|
2024-03-13 20:44:13 +00:00
|
|
|
renderProfileEditor={renderProfileEditor}
|
|
|
|
renderUsernameOnboarding={renderUsernameOnboarding}
|
|
|
|
renderSafetyNumber={renderSafetyNumber}
|
|
|
|
renderSendAnywayDialog={renderSendAnywayDialog}
|
|
|
|
renderShortcutGuideModal={renderShortcutGuideModal}
|
|
|
|
renderStickerPreviewModal={renderStickerPreviewModal}
|
|
|
|
renderStoriesSettings={renderStoriesSettings}
|
|
|
|
safetyNumberChangedBlockingData={safetyNumberChangedBlockingData}
|
|
|
|
safetyNumberModalContactId={safetyNumberModalContactId}
|
|
|
|
stickerPackPreviewId={stickerPackPreviewId}
|
|
|
|
theme={theme}
|
|
|
|
toggleSignalConnectionsModal={toggleSignalConnectionsModal}
|
|
|
|
userNotFoundModalState={userNotFoundModalState}
|
|
|
|
usernameOnboardingState={usernameOnboardingState}
|
2021-10-06 20:27:14 +00:00
|
|
|
/>
|
2024-03-13 20:44:13 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|