signal-desktop/ts/components/GlobalModalContainer.tsx

59 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-05-28 16:15:17 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
2021-09-21 22:37:10 +00:00
import { ContactModalStateType } from '../state/ducks/globalModals';
import { LocalizerType } from '../types/Util';
import { WhatsNewModal } from './WhatsNewModal';
2021-09-21 22:37:10 +00:00
2021-05-28 16:15:17 +00:00
type PropsType = {
i18n: LocalizerType;
2021-09-21 22:37:10 +00:00
// ContactModal
contactModalState?: ContactModalStateType;
renderContactModal: () => JSX.Element;
2021-07-19 19:26:06 +00:00
// ProfileEditor
isProfileEditorVisible: boolean;
renderProfileEditor: () => JSX.Element;
// SafetyNumberModal
safetyNumberModalContactId?: string;
renderSafetyNumber: () => JSX.Element;
// WhatsNewModal
isWhatsNewVisible: boolean;
hideWhatsNewModal: () => unknown;
2021-05-28 16:15:17 +00:00
};
export const GlobalModalContainer = ({
i18n,
2021-09-21 22:37:10 +00:00
// ContactModal
contactModalState,
renderContactModal,
2021-07-19 19:26:06 +00:00
// ProfileEditor
isProfileEditorVisible,
renderProfileEditor,
// SafetyNumberModal
safetyNumberModalContactId,
renderSafetyNumber,
// WhatsNewModal
hideWhatsNewModal,
isWhatsNewVisible,
2021-05-28 16:15:17 +00:00
}: PropsType): JSX.Element | null => {
if (safetyNumberModalContactId) {
return renderSafetyNumber();
}
2021-09-21 22:37:10 +00:00
if (contactModalState) {
return renderContactModal();
}
2021-07-19 19:26:06 +00:00
if (isProfileEditorVisible) {
return renderProfileEditor();
}
if (isWhatsNewVisible) {
return <WhatsNewModal hideWhatsNewModal={hideWhatsNewModal} i18n={i18n} />;
}
2021-05-28 16:15:17 +00:00
return null;
};