Fix: Prevent notification prompt from reappearing after timeout
**Issue:** - Notification prompt kept reappearing after push subscription timeout - Users stuck in loop when push notifications fail due to network restrictions **Solution:** - Auto-dismiss prompt on timeout errors - Mark as permanently declined when timeout occurs - Provide user-friendly error message - Clean up error handling flow **Technical Changes:** - Check for timeout in error message - Set both session and permanent dismissal flags - Simplify error propagation from enableNotifications() - Show concise error message for timeout scenarios This fix ensures users in restricted network environments (VPNs, corporate firewalls, FCM blocked) won't be repeatedly prompted for push notifications that can't work. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5adf1b90d5
commit
cd479d8946
@ -113,7 +113,17 @@ class AdminNotificationManager {
|
||||
sessionStorage.setItem('notificationPromptDismissed', 'true');
|
||||
} catch (error) {
|
||||
console.error('Failed to enable notifications:', error);
|
||||
this.showNotificationError('Failed to enable notifications. Please try again.');
|
||||
|
||||
// Check if it's a timeout error - if so, dismiss the prompt
|
||||
if (error.message && error.message.includes('timed out')) {
|
||||
promptDiv.remove();
|
||||
sessionStorage.setItem('notificationPromptDismissed', 'true');
|
||||
localStorage.setItem('pushNotificationDeclined', 'true');
|
||||
|
||||
this.showNotificationError('Push notifications timed out. This may be due to network restrictions. The app will work without push notifications.');
|
||||
} else {
|
||||
this.showNotificationError('Failed to enable notifications. Please try again.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -148,31 +158,13 @@ class AdminNotificationManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to enable notifications:', error);
|
||||
|
||||
// Show enhanced error message with diagnostics
|
||||
let errorMessage = '❌ Failed to enable push notifications.\n\n';
|
||||
|
||||
if (error.message.includes('timed out') && error.message.includes('FCM')) {
|
||||
errorMessage += '🔗 Network Issue Detected:\n';
|
||||
errorMessage += 'Your browser cannot connect to Chrome\'s push notification service (FCM). ';
|
||||
errorMessage += 'This commonly happens with:\n';
|
||||
errorMessage += '• Corporate firewalls or VPNs\n';
|
||||
errorMessage += '• Network security software\n';
|
||||
errorMessage += '• Restricted internet connections\n\n';
|
||||
errorMessage += '💡 Workarounds:\n';
|
||||
errorMessage += '• Try from a different network\n';
|
||||
errorMessage += '• Disable VPN temporarily\n';
|
||||
errorMessage += '• Contact your IT department\n';
|
||||
errorMessage += '• Use a mobile hotspot to test\n\n';
|
||||
errorMessage += 'The admin panel will still work normally - you just won\'t receive push notifications.';
|
||||
} else {
|
||||
errorMessage += `Error: ${error.message}`;
|
||||
}
|
||||
|
||||
this.showNotificationError(errorMessage);
|
||||
// Re-throw so the caller can handle it
|
||||
throw error;
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
button.innerHTML = originalText;
|
||||
if (button) {
|
||||
button.disabled = false;
|
||||
button.innerHTML = originalText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user