2021-05-06 00:09:29 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo, useCallback } from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
2021-05-06 00:09:29 +00:00
|
|
|
import { CaptchaDialog } from '../../components/CaptchaDialog';
|
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
import { isChallengePending } from '../selectors/network';
|
|
|
|
import { getChallengeURL } from '../../challenge';
|
2023-04-06 21:49:24 +00:00
|
|
|
import * as log from '../../logging/log';
|
2021-05-06 00:09:29 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export type SmartCaptchaDialogProps = Readonly<{
|
|
|
|
onSkip: () => void;
|
|
|
|
}>;
|
2021-05-06 00:09:29 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
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}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|