signal-desktop/ts/state/smart/CaptchaDialog.tsx
Jamie Kyle 27b55e472d
Refactor smart components
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
2024-03-13 13:44:13 -07:00

33 lines
1 KiB
TypeScript

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { memo, useCallback } from 'react';
import { useSelector } from 'react-redux';
import { CaptchaDialog } from '../../components/CaptchaDialog';
import { getIntl } from '../selectors/user';
import { isChallengePending } from '../selectors/network';
import { getChallengeURL } from '../../challenge';
import * as log from '../../logging/log';
export type SmartCaptchaDialogProps = Readonly<{
onSkip: () => void;
}>;
export const SmartCaptchaDialog = memo(function SmartCaptchaDialog({
onSkip,
}: SmartCaptchaDialogProps) {
const i18n = useSelector(getIntl);
const isPending = useSelector(isChallengePending);
const handleContinue = useCallback(() => {
const url = getChallengeURL('chat');
log.info(`CaptchaDialog: navigating to ${url}`);
document.location.href = url;
}, []);
return (
<CaptchaDialog
i18n={i18n}
isPending={isPending}
onSkip={onSkip}
onContinue={handleContinue}
/>
);
});