Move getUntrustedContacts out of conversation_view

This commit is contained in:
Josh Perez 2022-08-16 19:59:11 -04:00 committed by GitHub
parent 96c4cc4bcf
commit 936ce91b2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 410 additions and 414 deletions

View file

@ -52,11 +52,8 @@ type PropsType = {
export const App = ({
appView,
cancelConversationVerification,
conversationsStoppingSend,
executeMenuAction,
executeMenuRole,
getPreferredBadge,
hasInitialLoadCompleted,
hasSelectedStoryData,
hideMenuBar,
@ -75,7 +72,6 @@ export const App = ({
renderCustomizingPreferredReactionsModal,
renderGlobalModalContainer,
renderLeftPane,
renderSafetyNumber,
renderStories,
renderStoryViewer,
requestVerification,
@ -86,7 +82,6 @@ export const App = ({
theme,
titleBarDoubleClick,
toastType,
verifyConversationsStoppingSend,
}: PropsType): JSX.Element => {
let contents;
@ -107,23 +102,17 @@ export const App = ({
} else if (appView === AppViewType.Inbox) {
contents = (
<Inbox
cancelConversationVerification={cancelConversationVerification}
conversationsStoppingSend={conversationsStoppingSend}
hasInitialLoadCompleted={hasInitialLoadCompleted}
getPreferredBadge={getPreferredBadge}
i18n={i18n}
isCustomizingPreferredReactions={isCustomizingPreferredReactions}
renderCustomizingPreferredReactionsModal={
renderCustomizingPreferredReactionsModal
}
renderLeftPane={renderLeftPane}
renderSafetyNumber={renderSafetyNumber}
selectedConversationId={selectedConversationId}
selectedMessage={selectedMessage}
showConversation={showConversation}
showWhatsNewModal={showWhatsNewModal}
theme={theme}
verifyConversationsStoppingSend={verifyConversationsStoppingSend}
/>
);
}

View file

@ -25,6 +25,7 @@ export type OwnProps = Readonly<{
hasXButton?: boolean;
i18n: LocalizerType;
moduleClassName?: string;
noMouseClose?: boolean;
onCancel?: () => unknown;
onClose: () => unknown;
onTopOfEverything?: boolean;
@ -56,18 +57,19 @@ function getButtonVariant(
export const ConfirmationDialog = React.memo(
({
moduleClassName,
actions = [],
cancelButtonVariant,
cancelText,
children,
hasXButton,
i18n,
moduleClassName,
noMouseClose,
onCancel,
onClose,
onTopOfEverything,
theme,
title,
hasXButton,
cancelButtonVariant,
onTopOfEverything,
}: Props) => {
const { close, overlayStyles, modalStyles } = useAnimated(onClose, {
getFrom: () => ({ opacity: 0, transform: 'scale(0.25)' }),
@ -94,10 +96,11 @@ export const ConfirmationDialog = React.memo(
return (
<ModalHost
onTopOfEverything={onTopOfEverything}
noMouseClose={noMouseClose}
onClose={close}
theme={theme}
onTopOfEverything={onTopOfEverything}
overlayStyles={overlayStyles}
theme={theme}
>
<animated.div style={modalStyles}>
<ModalWindow

View file

@ -6,6 +6,7 @@ import type {
ContactModalStateType,
ForwardMessagePropsType,
UserNotFoundModalStateType,
SafetyNumberChangedBlockingDataType,
} from '../state/ducks/globalModals';
import type { LocalizerType } from '../types/Util';
import { missingCaseError } from '../util/missingCaseError';
@ -35,6 +36,10 @@ type PropsType = {
// StoriesSettings
isStoriesSettingsVisible: boolean;
renderStoriesSettings: () => JSX.Element;
// SendAnywayDialog
hasSafetyNumberChangeModal: boolean;
safetyNumberChangedBlockingData?: SafetyNumberChangedBlockingDataType;
renderSendAnywayDialog: () => JSX.Element;
// UserNotFoundModal
hideUserNotFoundModal: () => unknown;
userNotFoundModalState?: UserNotFoundModalStateType;
@ -63,6 +68,10 @@ export const GlobalModalContainer = ({
// StoriesSettings
isStoriesSettingsVisible,
renderStoriesSettings,
// SendAnywayDialog
hasSafetyNumberChangeModal,
safetyNumberChangedBlockingData,
renderSendAnywayDialog,
// UserNotFoundModal
hideUserNotFoundModal,
userNotFoundModalState,
@ -70,6 +79,12 @@ export const GlobalModalContainer = ({
hideWhatsNewModal,
isWhatsNewVisible,
}: PropsType): JSX.Element | null => {
// We want the send anyway dialog to supersede most modals since this is an
// immediate action the user needs to take.
if (hasSafetyNumberChangeModal || safetyNumberChangedBlockingData) {
return renderSendAnywayDialog();
}
if (safetyNumberModalContactId) {
return renderSafetyNumber();
}

View file

@ -5,57 +5,39 @@ import type { ReactNode } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import type { ConversationModel } from '../models/conversations';
import type {
ConversationType,
ShowConversationType,
} from '../state/ducks/conversations';
import type { ShowConversationType } from '../state/ducks/conversations';
import type { ConversationView } from '../views/conversation_view';
import type { LocalizerType, ThemeType } from '../types/Util';
import type { PreferredBadgeSelectorType } from '../state/selectors/badges';
import type { SafetyNumberProps } from './SafetyNumberChangeDialog';
import type { LocalizerType } from '../types/Util';
import * as log from '../logging/log';
import { SECOND } from '../util/durations';
import { SafetyNumberChangeDialog } from './SafetyNumberChangeDialog';
import { ToastStickerPackInstallFailed } from './ToastStickerPackInstallFailed';
import { WhatsNewLink } from './WhatsNewLink';
import { showToast } from '../util/showToast';
import { strictAssert } from '../util/assert';
export type PropsType = {
cancelConversationVerification: () => void;
conversationsStoppingSend: Array<ConversationType>;
hasInitialLoadCompleted: boolean;
getPreferredBadge: PreferredBadgeSelectorType;
i18n: LocalizerType;
isCustomizingPreferredReactions: boolean;
renderCustomizingPreferredReactionsModal: () => JSX.Element;
renderLeftPane: () => JSX.Element;
renderSafetyNumber: (props: SafetyNumberProps) => JSX.Element;
selectedConversationId?: string;
selectedMessage?: string;
showConversation: ShowConversationType;
showWhatsNewModal: () => unknown;
theme: ThemeType;
verifyConversationsStoppingSend: () => void;
};
export const Inbox = ({
cancelConversationVerification,
conversationsStoppingSend,
hasInitialLoadCompleted,
getPreferredBadge,
i18n,
isCustomizingPreferredReactions,
renderCustomizingPreferredReactionsModal,
renderLeftPane,
renderSafetyNumber,
selectedConversationId,
selectedMessage,
showConversation,
showWhatsNewModal,
theme,
verifyConversationsStoppingSend,
}: PropsType): JSX.Element => {
const [loadingMessageCount, setLoadingMessageCount] = useState(0);
const [internalHasInitialLoadCompleted, setInternalHasInitialLoadCompleted] =
@ -226,21 +208,7 @@ export const Inbox = ({
}
let activeModal: ReactNode;
if (conversationsStoppingSend.length) {
activeModal = (
<SafetyNumberChangeDialog
confirmText={i18n('safetyNumberChangeDialog__pending-messages')}
contacts={conversationsStoppingSend}
getPreferredBadge={getPreferredBadge}
i18n={i18n}
onCancel={cancelConversationVerification}
onConfirm={verifyConversationsStoppingSend}
renderSafetyNumber={renderSafetyNumber}
theme={theme}
/>
);
}
if (!activeModal && isCustomizingPreferredReactions) {
if (isCustomizingPreferredReactions) {
activeModal = renderCustomizingPreferredReactionsModal();
}

View file

@ -14,6 +14,11 @@ import type { PreferredBadgeSelectorType } from '../state/selectors/badges';
import type { LocalizerType, ThemeType } from '../types/Util';
import { isInSystemContacts } from '../util/isInSystemContacts';
export enum SafetyNumberChangeSource {
Calling = 'Calling',
MessageSend = 'MessageSend',
}
export type SafetyNumberProps = {
contactID: string;
onClose: () => void;
@ -75,6 +80,7 @@ export const SafetyNumberChangeDialog = ({
},
]}
i18n={i18n}
noMouseClose
onCancel={onClose}
onClose={noop}
title={i18n('safetyNumberChanges')}