From 1b2a5af2be338963e69f3123121dd874a4bb0989 Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Sun, 21 Jun 2026 01:45:05 +0400 Subject: [PATCH] test --- .../telegram-login.component.ts | 63 +------------------ 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/src/app/components/telegram-login/telegram-login.component.ts b/src/app/components/telegram-login/telegram-login.component.ts index f500bfa..ec5c078 100644 --- a/src/app/components/telegram-login/telegram-login.component.ts +++ b/src/app/components/telegram-login/telegram-login.component.ts @@ -42,7 +42,6 @@ export class TelegramLoginComponent implements OnDestroy { this.initQrLogin(); } else { this.awaitingTelegramReturn.set(false); - this.clearTelegramFallback(); this.stopPolling(); } }); @@ -56,7 +55,6 @@ export class TelegramLoginComponent implements OnDestroy { ngOnDestroy(): void { this.awaitingTelegramReturn.set(false); - this.clearTelegramFallback(); this.stopPolling(); if (typeof window !== 'undefined') { @@ -68,53 +66,30 @@ export class TelegramLoginComponent implements OnDestroy { close(): void { this.awaitingTelegramReturn.set(false); - this.clearTelegramFallback(); this.authService.hideLogin(); this.stopPolling(); } openTelegramLogin(): void { - const url = this.loginUrl(); const webSessionID = this.webSessionID(); - if (!url || !webSessionID) return; + if (!webSessionID || typeof window === 'undefined') return; if (!this.pollTimer) { this.startPolling(webSessionID); } - const appUrl = this.authService.getTelegramAppLoginUrl(webSessionID); this.awaitingTelegramReturn.set(true); - this.clearTelegramFallback(); - - if (this.isMobileBrowser()) { - window.location.href = appUrl; - return; - } - - this.openExternalApp(appUrl); - this.telegramFallbackTimer = window.setTimeout(() => { - if (!this.showDialog() || !this.awaitingTelegramReturn()) { - return; - } - - if (typeof document !== 'undefined' && (!document.hasFocus() || document.visibilityState === 'hidden')) { - return; - } - - window.open(url, '_blank', 'noopener,noreferrer'); - }, 1200); + window.location.href = this.authService.getTelegramAppLoginUrl(webSessionID); } refreshQr(): void { this.awaitingTelegramReturn.set(false); - this.clearTelegramFallback(); this.stopPolling(); this.initQrLogin(); } private initQrLogin(): void { this.awaitingTelegramReturn.set(false); - this.clearTelegramFallback(); this.qrStatus.set('loading'); this.loginUrl.set(''); this.webSessionID.set(''); @@ -149,7 +124,6 @@ export class TelegramLoginComponent implements OnDestroy { next: (session) => { if (session?.active) { this.awaitingTelegramReturn.set(false); - this.clearTelegramFallback(); this.stopPolling(); this.authService.onTelegramLoginComplete(); } @@ -168,13 +142,6 @@ export class TelegramLoginComponent implements OnDestroy { } } - private clearTelegramFallback(): void { - if (this.telegramFallbackTimer) { - clearTimeout(this.telegramFallbackTimer); - this.telegramFallbackTimer = undefined; - } - } - private checkLoginAfterReturn(): void { if (!this.showDialog() || !this.awaitingTelegramReturn()) { return; @@ -193,35 +160,9 @@ export class TelegramLoginComponent implements OnDestroy { this.authService.checkSessionOnce(webSessionID).subscribe(session => { if (session?.active) { this.awaitingTelegramReturn.set(false); - this.clearTelegramFallback(); this.stopPolling(); this.authService.onTelegramLoginComplete(); } }); } - - private openExternalApp(url: string): void { - if (typeof document === 'undefined') { - window.location.href = url; - return; - } - - const anchor = document.createElement('a'); - anchor.href = url; - anchor.style.display = 'none'; - document.body.appendChild(anchor); - anchor.click(); - anchor.remove(); - } - - private isMobileBrowser(): boolean { - if (typeof navigator === 'undefined') { - return false; - } - - const userAgent = navigator.userAgent || navigator.vendor; - const isTouchMac = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1; - - return /Android|iPhone|iPad|iPod|IEMobile|Opera Mini/i.test(userAgent) || isTouchMac; - } }