2022-08-16 23:59:11 +00:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import type { LocalizerType } from '../../types/Util';
|
|
|
|
import type { SafetyNumberChangedBlockingDataType } from '../ducks/globalModals';
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import * as SingleServePromise from '../../services/singleServePromise';
|
|
|
|
import {
|
|
|
|
SafetyNumberChangeDialog,
|
|
|
|
SafetyNumberChangeSource,
|
|
|
|
} from '../../components/SafetyNumberChangeDialog';
|
|
|
|
import { SmartSafetyNumberViewer } from './SafetyNumberViewer';
|
2022-11-11 04:10:30 +00:00
|
|
|
import { getByDistributionListConversationsStoppingSend } from '../selectors/conversations-extra';
|
2022-08-16 23:59:11 +00:00
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
|
|
|
import { useGlobalModalActions } from '../ducks/globalModals';
|
2022-11-11 04:10:30 +00:00
|
|
|
import { useStoryDistributionListsActions } from '../ducks/storyDistributionLists';
|
2022-08-16 23:59:11 +00:00
|
|
|
|
|
|
|
export function SmartSendAnywayDialog(): JSX.Element {
|
|
|
|
const { hideBlockingSafetyNumberChangeDialog } = useGlobalModalActions();
|
2022-11-11 04:10:30 +00:00
|
|
|
const { removeMembersFromDistributionList } =
|
|
|
|
useStoryDistributionListsActions();
|
2022-08-16 23:59:11 +00:00
|
|
|
const { cancelConversationVerification, verifyConversationsStoppingSend } =
|
|
|
|
useConversationsActions();
|
|
|
|
const getPreferredBadge = useSelector(getPreferredBadgeSelector);
|
|
|
|
const i18n = useSelector<StateType, LocalizerType>(getIntl);
|
|
|
|
const theme = useSelector(getTheme);
|
|
|
|
|
2022-11-11 04:10:30 +00:00
|
|
|
const contacts = useSelector(getByDistributionListConversationsStoppingSend);
|
2022-08-16 23:59:11 +00:00
|
|
|
|
|
|
|
const safetyNumberChangedBlockingData = useSelector<
|
|
|
|
StateType,
|
|
|
|
SafetyNumberChangedBlockingDataType | undefined
|
|
|
|
>(state => state.globalModals.safetyNumberChangedBlockingData);
|
|
|
|
|
|
|
|
const explodedPromise = safetyNumberChangedBlockingData
|
|
|
|
? SingleServePromise.get<boolean>(
|
|
|
|
safetyNumberChangedBlockingData.promiseUuid
|
|
|
|
)
|
|
|
|
: undefined;
|
|
|
|
|
|
|
|
let confirmText: string | undefined = i18n(
|
2023-03-30 00:03:25 +00:00
|
|
|
'icu:safetyNumberChangeDialog__pending-messages'
|
2022-08-16 23:59:11 +00:00
|
|
|
);
|
2023-09-06 00:34:51 +00:00
|
|
|
if (
|
|
|
|
safetyNumberChangedBlockingData?.source ===
|
|
|
|
SafetyNumberChangeSource.InitiateCall
|
|
|
|
) {
|
|
|
|
confirmText = i18n('icu:callAnyway');
|
|
|
|
} else if (
|
|
|
|
safetyNumberChangedBlockingData?.source ===
|
|
|
|
SafetyNumberChangeSource.JoinCall
|
|
|
|
) {
|
|
|
|
confirmText = i18n('icu:joinAnyway');
|
|
|
|
} else {
|
|
|
|
confirmText = undefined;
|
2022-08-16 23:59:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SafetyNumberChangeDialog
|
|
|
|
confirmText={confirmText}
|
|
|
|
contacts={contacts}
|
|
|
|
getPreferredBadge={getPreferredBadge}
|
|
|
|
i18n={i18n}
|
|
|
|
onCancel={() => {
|
|
|
|
cancelConversationVerification();
|
|
|
|
explodedPromise?.resolve(false);
|
|
|
|
hideBlockingSafetyNumberChangeDialog();
|
|
|
|
}}
|
|
|
|
onConfirm={() => {
|
|
|
|
verifyConversationsStoppingSend();
|
|
|
|
explodedPromise?.resolve(true);
|
|
|
|
hideBlockingSafetyNumberChangeDialog();
|
|
|
|
}}
|
2022-11-11 04:10:30 +00:00
|
|
|
removeFromStory={removeMembersFromDistributionList}
|
2022-08-16 23:59:11 +00:00
|
|
|
renderSafetyNumber={({ contactID, onClose }) => (
|
|
|
|
<SmartSafetyNumberViewer contactID={contactID} onClose={onClose} />
|
|
|
|
)}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|