import QrCreator from 'qr-creator'; import React, { FC, useEffect, useRef, memo, } from '../../lib/teact/teact'; import { withGlobal } from '../../lib/teact/teactn'; import { GlobalState, GlobalActions } from '../../global/types'; import { pick } from '../../util/iteratees'; import Loading from '../ui/Loading'; import Button from '../ui/Button'; import buildClassName from '../../util/buildClassName'; import useHistoryBack from '../../hooks/useHistoryBack'; type StateProps = Pick; type DispatchProps = Pick; const DATA_PREFIX = 'tg://login?token='; const AuthCode: FC = ({ connectionState, authQrCode, returnToAuthPhoneNumber, }) => { // eslint-disable-next-line no-null/no-null const qrCodeRef = useRef(null); useEffect(() => { if (!authQrCode || connectionState !== 'connectionStateReady') { return; } const container = qrCodeRef.current!; container.innerHTML = ''; container.classList.remove('pre-animate'); QrCreator.render({ text: `${DATA_PREFIX}${authQrCode.token}`, radius: 0.5, ecLevel: 'M', fill: '#4E96D4', size: 280, }, container); }, [connectionState, authQrCode]); useHistoryBack(returnToAuthPhoneNumber); return (
{!authQrCode && }

Log in to Telegram by QR Code

  1. Open Telegram on your phone
  2. Go to Settings > Devices > Scan QR
  3. Point your phone at this screen to confirm login
); }; export default memo(withGlobal( (global): StateProps => pick(global, ['connectionState', 'authQrCode']), (setGlobal, actions): DispatchProps => pick(actions, ['returnToAuthPhoneNumber']), )(AuthCode));