From 34ec53495ecc9d304151405fac8f2ef7c5dbc36d Mon Sep 17 00:00:00 2001 From: Egor Date: Mon, 19 Jan 2026 07:57:23 +0300 Subject: [PATCH 1/2] Add files via upload --- src/components/ConnectionModal.tsx | 5 +- src/components/TopUpModal.tsx | 84 ++++++------------------------ 2 files changed, 18 insertions(+), 71 deletions(-) diff --git a/src/components/ConnectionModal.tsx b/src/components/ConnectionModal.tsx index ef89184..0d4f22f 100644 --- a/src/components/ConnectionModal.tsx +++ b/src/components/ConnectionModal.tsx @@ -227,8 +227,9 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) { if (isCustomScheme && tg?.openLink) { // For custom URL schemes - open redirect page in external browser via Telegram + // try_browser: true - показывает диалог для перехода во внешний браузер (важно для мобильных) try { - tg.openLink(redirectUrl, { try_instant_view: false }) + tg.openLink(redirectUrl, { try_instant_view: false, try_browser: true }) return } catch (e) { console.warn('tg.openLink failed:', e) @@ -286,7 +287,7 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) {

{t('subscription.connection.title')}

- @@ -142,29 +141,6 @@ export default function Support() { const createFileInputRef = useRef(null) const replyFileInputRef = useRef(null) - // Cleanup function to revoke object URLs and prevent memory leaks - const clearAttachment = useCallback(( - attachment: MediaAttachment | null, - setAttachment: (a: MediaAttachment | null) => void - ) => { - if (attachment?.preview) { - URL.revokeObjectURL(attachment.preview) - } - setAttachment(null) - }, []) - - // Cleanup on unmount to prevent memory leaks - useEffect(() => { - return () => { - if (createAttachment?.preview) { - URL.revokeObjectURL(createAttachment.preview) - } - if (replyAttachment?.preview) { - URL.revokeObjectURL(replyAttachment.preview) - } - } - }, []) // Empty deps - only run on unmount - // Get support configuration const { data: supportConfig, isLoading: configLoading } = useQuery({ queryKey: ['support-config'], @@ -186,14 +162,8 @@ export default function Support() { // Handle file selection const handleFileSelect = async ( file: File, - setAttachment: (a: MediaAttachment | null) => void, - currentAttachment: MediaAttachment | null + setAttachment: (a: MediaAttachment | null) => void ) => { - // Revoke old object URL before creating new one - if (currentAttachment?.preview) { - URL.revokeObjectURL(currentAttachment.preview) - } - // Validate file type const allowedTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'] if (!allowedTypes.includes(file.type)) { @@ -254,7 +224,7 @@ export default function Support() { setShowCreateForm(false) setNewTitle('') setNewMessage('') - clearAttachment(createAttachment, setCreateAttachment) + setCreateAttachment(null) setSelectedTicket(ticket) }, }) @@ -272,7 +242,7 @@ export default function Support() { onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['ticket', selectedTicket?.id] }) setReplyMessage('') - clearAttachment(replyAttachment, setReplyAttachment) + setReplyAttachment(null) }, }) @@ -348,7 +318,7 @@ export default function Support() { if (webApp?.openLink) { log.debug('Using openLink') try { - webApp.openLink(webUrl) + webApp.openLink(webUrl, { try_browser: true }) return } catch (e) { log.error('openLink failed:', e) @@ -370,7 +340,7 @@ export default function Support() { buttonAction: () => { const webApp = window.Telegram?.WebApp if (webApp?.openLink) { - webApp.openLink(supportConfig.support_url!) + webApp.openLink(supportConfig.support_url!, { try_browser: true }) } else { window.open(supportConfig.support_url!, '_blank') } @@ -402,7 +372,7 @@ export default function Support() { webApp.openTelegramLink(webUrl) } else if (webApp?.openLink) { log.debug('Fallback using openLink') - webApp.openLink(webUrl) + webApp.openLink(webUrl, { try_browser: true }) } else { log.debug('Fallback using window.open') window.open(webUrl, '_blank') @@ -473,7 +443,7 @@ export default function Support() { onClick={() => { setShowCreateForm(true) setSelectedTicket(null) - clearAttachment(createAttachment, setCreateAttachment) + setCreateAttachment(null) }} className="btn-primary" > @@ -499,7 +469,7 @@ export default function Support() { onClick={() => { setSelectedTicket(ticket as unknown as TicketDetail) setShowCreateForm(false) - clearAttachment(replyAttachment, setReplyAttachment) + setReplyAttachment(null) }} className={`w-full text-left p-4 rounded-xl border transition-all ${ selectedTicket?.id === ticket.id @@ -585,14 +555,14 @@ export default function Support() { className="hidden" onChange={(e) => { const file = e.target.files?.[0] - if (file) handleFileSelect(file, setCreateAttachment, createAttachment) + if (file) handleFileSelect(file, setCreateAttachment) e.target.value = '' }} /> {createAttachment ? ( clearAttachment(createAttachment, setCreateAttachment)} + onRemove={() => setCreateAttachment(null)} /> ) : (