Update useTelegramWebApp.ts

This commit is contained in:
Egor
2026-01-27 00:33:41 +03:00
committed by GitHub
parent 6856518fee
commit f293fb8b2b

View File

@@ -101,15 +101,23 @@ export function useTelegramWebApp() {
}, [isFullscreen, requestFullscreen, exitFullscreen])
const disableVerticalSwipes = useCallback(() => {
if (webApp?.disableVerticalSwipes) {
try {
if (webApp?.disableVerticalSwipes && webApp.version && webApp.version >= '7.7') {
webApp.disableVerticalSwipes()
}
} catch {
// Not supported in this version
}
}, [webApp])
const enableVerticalSwipes = useCallback(() => {
if (webApp?.enableVerticalSwipes) {
try {
if (webApp?.enableVerticalSwipes && webApp.version && webApp.version >= '7.7') {
webApp.enableVerticalSwipes()
}
} catch {
// Not supported in this version
}
}, [webApp])
// Check if fullscreen is supported (Bot API 8.0+)
@@ -140,10 +148,14 @@ export function initTelegramWebApp() {
webApp.ready()
webApp.expand()
// Disable vertical swipes to prevent accidental closing
if (webApp.disableVerticalSwipes) {
// Disable vertical swipes to prevent accidental closing (requires Bot API 7.7+)
try {
if (webApp.disableVerticalSwipes && webApp.version && webApp.version >= '7.7') {
webApp.disableVerticalSwipes()
}
} catch {
// Swipe control not supported in this version
}
// Auto-enter fullscreen if enabled in settings (use cached value for instant response)
const fullscreenEnabled = getCachedFullscreenEnabled()