diff --git a/components/_app/components/ConnectedAccounts.tsx b/components/_app/components/ConnectedAccounts.tsx index 277c0baa14..ee2e448b4f 100644 --- a/components/_app/components/ConnectedAccounts.tsx +++ b/components/_app/components/ConnectedAccounts.tsx @@ -137,27 +137,25 @@ function TelegramAccountConnect({ const { connectTelegram, isConnectingToTelegram } = useTelegramConnect(); return ( - <> - } - required={isTelegramRequired} - disabled={!!connectedTelegramAccount || isConnectingToTelegram} - onClick={() => { - setIsOnboardingModalOpen(true); - connectTelegram(); - }} - > - {!connectedTelegramAccount ? ( - Connect with Telegram - ) : ( - - Connected as {(connectedTelegramAccount.account as unknown as Partial)?.username} - - )} - + } + required={isTelegramRequired} + disabled={!!connectedTelegramAccount || isConnectingToTelegram} + onClick={() => { + setIsOnboardingModalOpen(true); + connectTelegram(); + }} + > + {!connectedTelegramAccount ? ( + Connect with Telegram + ) : ( + + Connected as {(connectedTelegramAccount.account as unknown as Partial)?.username} + + )} - + ); } diff --git a/components/settings/account/components/NewIdentityModal.tsx b/components/settings/account/components/NewIdentityModal.tsx index 7870c46f2d..cae90c0029 100644 --- a/components/settings/account/components/NewIdentityModal.tsx +++ b/components/settings/account/components/NewIdentityModal.tsx @@ -23,7 +23,7 @@ import type { TelegramAccount } from 'lib/telegram/interfaces'; import { lowerCaseEqual } from 'lib/utils/strings'; import IdentityProviderItem from './IdentityProviderItem'; -import { TELEGRAM_BOT_ID } from './TelegramLoginIframe'; +import { TELEGRAM_BOT_ID, TelegramLoginIframe } from './TelegramLoginIframe'; const WarpcastLogin = dynamic( () => import('components/login/components/WarpcastLogin').then((module) => module.WarpcastLogin), @@ -168,6 +168,7 @@ export function NewIdentityModal({ isOpen, onClose }: Props) { }} > Connect + )} diff --git a/components/settings/account/components/TelegramLoginIframe.tsx b/components/settings/account/components/TelegramLoginIframe.tsx index 95773da05b..6b1277eeea 100644 --- a/components/settings/account/components/TelegramLoginIframe.tsx +++ b/components/settings/account/components/TelegramLoginIframe.tsx @@ -10,36 +10,14 @@ export function loginWithTelegram(callback: (user: TelegramAccount) => void) { window.Telegram.Login.auth({ bot_id: TELEGRAM_BOT_ID, request_access: true }, callback); } -export class TelegramLoginIframe extends React.Component<{ - widgetVersion?: string; - children?: React.ReactNode; -}> { - instance: HTMLDivElement | null = null; - - componentDidMount() { +export function TelegramLoginIframe() { + const ref = React.useRef(null); + React.useEffect(() => { const script = document.createElement('script'); - script.src = `https://telegram.org/js/telegram-widget.js?${this.props.widgetVersion || ''}`; + script.src = 'https://telegram.org/js/telegram-widget.js?22'; script.async = true; - this.instance?.appendChild(script); - } + ref.current?.appendChild(script); + }, []); - render() { - return ( -
{ - this.instance = component; - }} - > - {this.props.children} -
- ); - } + return
; }