From 7fdf7a1b89ce51703a4fc3ffa78f08d786cd2a82 Mon Sep 17 00:00:00 2001 From: lockbitchat Date: Sat, 23 Aug 2025 17:48:46 -0400 Subject: [PATCH] Fix non-working PWA modal buttons - Fixed 'Got it' and 'Later' buttons in iOS Safari modal - Fixed 'Close' button in fallback instructions modal - Fixed 'OK' button in final dismissal notification - Replaced broken inline onclick with proper event listeners - Added comprehensive button event handling with logging Bug: Modal buttons were unresponsive due to inline onclick issues --- index.html | 2 +- src/pwa/install-prompt.js | 59 +++++++-------------------------------- 2 files changed, 11 insertions(+), 50 deletions(-) diff --git a/index.html b/index.html index 129972d..79a1bf0 100644 --- a/index.html +++ b/index.html @@ -3952,7 +3952,7 @@ if ('serviceWorker' in navigator) { if (isPWAInstalled) { // Если это PWA, показываем уведомление об обновлении - showUpdateNotification(); + showUpdateNotification(); } else { // Если это браузер, показываем промпт установки if (window.pwaInstallPrompt && !window.pwaInstallPrompt.isInstalled) { diff --git a/src/pwa/install-prompt.js b/src/pwa/install-prompt.js index d7247dd..92e5212 100644 --- a/src/pwa/install-prompt.js +++ b/src/pwa/install-prompt.js @@ -7,7 +7,6 @@ class PWAInstallPrompt { this.dismissedCount = 0; this.maxDismissals = 3; this.installationChecked = false; - this.delayedPromptTimeout = null; this.init(); } @@ -25,9 +24,6 @@ class PWAInstallPrompt { this.startInstallationMonitoring(); } - // Автоматический показ модального окна через 10 секунд для новых пользователей - this.scheduleDelayedPrompt(); - console.log('✅ PWA Install Prompt initialized'); } @@ -99,30 +95,6 @@ class PWAInstallPrompt { }); } - scheduleDelayedPrompt() { - // Автоматический показ модального окна через 10 секунд для новых пользователей - this.delayedPromptTimeout = setTimeout(() => { - console.log('⏰ Checking if delayed install prompt should be shown...'); - - // Проверяем, нужно ли показывать промпт - if (!this.isInstalled && this.shouldShowPrompt()) { - console.log('💿 Showing delayed install modal after 10 seconds'); - - // Для iOS Safari показываем модальное окно с инструкциями - if (this.isIOSSafari()) { - this.showIOSInstallInstructions(); - } else { - // Для других устройств показываем fallback инструкции - this.showFallbackInstructions(); - } - } else { - console.log('💿 Delayed install prompt not shown - app is installed or dismissed'); - } - }, 10000); // 10 секунд - - console.log('⏰ Delayed install prompt scheduled for 10 seconds'); - } - setupEventListeners() { window.addEventListener('beforeinstallprompt', (event) => { console.log('💿 Install prompt event captured'); @@ -251,21 +223,11 @@ class PWAInstallPrompt { return; } - // Отменяем отложенный промпт, так как показываем промпт сейчас - if (this.delayedPromptTimeout) { - clearTimeout(this.delayedPromptTimeout); - this.delayedPromptTimeout = null; - console.log('⏰ Delayed install prompt cancelled - showing prompt now'); - } - - // Для мобильных устройств показываем модальные окна, а не кнопки if (this.isIOSSafari()) { - this.showIOSInstallInstructions(); + this.showInstallButton(); } else if (this.isMobileDevice()) { - // Для мобильных показываем fallback инструкции вместо баннера - this.showFallbackInstructions(); + this.showInstallBanner(); } else { - // Для десктопа показываем кнопку this.showInstallButton(); } } @@ -323,13 +285,6 @@ class PWAInstallPrompt { hideInstallPrompts() { console.log('💿 Hiding all install prompts'); - // Отменяем отложенный промпт - if (this.delayedPromptTimeout) { - clearTimeout(this.delayedPromptTimeout); - this.delayedPromptTimeout = null; - console.log('⏰ Delayed install prompt cancelled'); - } - if (this.installButton) { this.installButton.classList.add('hidden'); console.log('💿 Install button hidden'); @@ -634,14 +589,20 @@ class PWAInstallPrompt {
You can still install SecureBit.chat from your browser's menu for the best experience.
- `; + // Добавляем обработчик события для кнопки OK + const okBtn = notification.querySelector('.ok-btn'); + okBtn.addEventListener('click', () => { + notification.remove(); + console.log('✅ Final dismissal message acknowledged'); + }); + document.body.appendChild(notification); setTimeout(() => {