-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
GlobalModalContainer.tsx
58 lines (50 loc) · 1.37 KB
/
GlobalModalContainer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { ContactModalStateType } from '../state/ducks/globalModals';
import { LocalizerType } from '../types/Util';
import { WhatsNewModal } from './WhatsNewModal';
type PropsType = {
i18n: LocalizerType;
// ContactModal
contactModalState?: ContactModalStateType;
renderContactModal: () => JSX.Element;
// ProfileEditor
isProfileEditorVisible: boolean;
renderProfileEditor: () => JSX.Element;
// SafetyNumberModal
safetyNumberModalContactId?: string;
renderSafetyNumber: () => JSX.Element;
// WhatsNewModal
isWhatsNewVisible: boolean;
hideWhatsNewModal: () => unknown;
};
export const GlobalModalContainer = ({
i18n,
// ContactModal
contactModalState,
renderContactModal,
// ProfileEditor
isProfileEditorVisible,
renderProfileEditor,
// SafetyNumberModal
safetyNumberModalContactId,
renderSafetyNumber,
// WhatsNewModal
hideWhatsNewModal,
isWhatsNewVisible,
}: PropsType): JSX.Element | null => {
if (safetyNumberModalContactId) {
return renderSafetyNumber();
}
if (contactModalState) {
return renderContactModal();
}
if (isProfileEditorVisible) {
return renderProfileEditor();
}
if (isWhatsNewVisible) {
return <WhatsNewModal hideWhatsNewModal={hideWhatsNewModal} i18n={i18n} />;
}
return null;
};