chore: remove debug logging and disable debug mode for production

- Removed temporary console logs used for debugging
- Disabled DEBUG_MODE flag
- Updated configuration to run in production mode
- Cleaned up leftover debug utilities to reduce noise in console
This commit is contained in:
lockbitchat
2025-10-02 01:43:32 -04:00
parent 5ce6db1640
commit 65cc136b99
21 changed files with 2308 additions and 3162 deletions
+5 -57
View File
@@ -12,14 +12,10 @@ class PWAInstallPrompt {
}
init() {
console.log('💿 PWA Install Prompt initializing...');
this.checkInstallationStatus();
if (this.isInstalled) {
console.log('💿 App already installed, skipping initialization');
return;
}
this.setupEventListeners();
this.createInstallButton();
@@ -28,23 +24,15 @@ class PWAInstallPrompt {
if (this.isIOSSafari()) {
this.startInstallationMonitoring();
}
console.log('✅ PWA Install Prompt initialized');
}
checkInstallationStatus() {
console.log('🔍 Checking PWA installation status...');
const isStandalone = window.matchMedia('(display-mode: standalone)').matches;
const isIOSStandalone = window.navigator.standalone === true;
const hasInstallPreference = this.loadInstallPreferences().installed;
console.log('🔍 PWA Installation Check:', {
isStandalone,
isIOSStandalone,
hasInstallPreference,
userAgent: navigator.userAgent.slice(0, 100)
});
if (isStandalone || isIOSStandalone || hasInstallPreference) {
this.isInstalled = true;
@@ -81,7 +69,6 @@ class PWAInstallPrompt {
const isStandalone = window.navigator.standalone;
if (isStandalone && !wasStandalone && !this.isInstalled) {
console.log('✅ iOS PWA installation detected');
this.isInstalled = true;
this.hideInstallPrompts();
this.showInstallSuccess();
@@ -109,7 +96,6 @@ class PWAInstallPrompt {
setupEventListeners() {
window.addEventListener('beforeinstallprompt', (event) => {
console.log('💿 Install prompt event captured');
event.preventDefault();
this.deferredPrompt = event;
@@ -123,7 +109,6 @@ class PWAInstallPrompt {
});
window.addEventListener('appinstalled', () => {
console.log('✅ PWA installed successfully');
this.isInstalled = true;
this.hideInstallPrompts();
this.showInstallSuccess();
@@ -141,7 +126,6 @@ class PWAInstallPrompt {
this.checkInstallationStatus();
if (!wasInstalled && this.isInstalled) {
console.log('✅ PWA installation detected on visibility change');
this.hideInstallPrompts();
this.showInstallSuccess();
}
@@ -154,7 +138,6 @@ class PWAInstallPrompt {
this.checkInstallationStatus();
if (!wasInstalled && this.isInstalled) {
console.log('✅ PWA installation detected on window focus');
this.hideInstallPrompts();
this.showInstallSuccess();
}
@@ -246,10 +229,6 @@ class PWAInstallPrompt {
}
showInstallOptions() {
if (this.checkInstallationStatus()) {
console.log('💿 App is installed, not showing install options');
return;
}
if (this.isIOSSafari()) {
this.showInstallButton();
@@ -261,10 +240,7 @@ class PWAInstallPrompt {
}
showInstallButton() {
if (this.checkInstallationStatus()) {
console.log('💿 App is installed, not showing install button');
return;
}
if (this.installButton && !this.isInstalled) {
this.installButton.classList.remove('hidden');
@@ -276,16 +252,13 @@ class PWAInstallPrompt {
this.installButton.style.transform = 'scale(1)';
}, 200);
}, 100);
console.log('💿 Install button shown');
} else {
console.log('💿 Install button not shown - app is installed or button not available');
}
}
showInstallBanner() {
if (this.checkInstallationStatus()) {
console.log('💿 App is installed, not showing install banner');
return;
}
@@ -298,15 +271,12 @@ class PWAInstallPrompt {
this.installBanner.classList.add('show');
this.installBanner.style.transform = 'translateY(0)';
}, 1000);
console.log('💿 Install banner shown');
} else {
console.log('💿 Install banner not shown - app is installed or banner not available');
}
}
hideInstallPrompts() {
console.log('💿 Hiding all install prompts');
if (this.installButton) {
this.installButton.classList.add('hidden');
@@ -328,7 +298,6 @@ class PWAInstallPrompt {
}
}, 300);
}
console.log('💿 Install banner hidden');
}
}
@@ -345,19 +314,15 @@ class PWAInstallPrompt {
}
try {
console.log('💿 Showing install prompt...');
const result = await this.deferredPrompt.prompt();
console.log('💿 Install prompt result:', result.outcome);
if (result.outcome === 'accepted') {
console.log('✅ User accepted install prompt');
this.isInstalled = true;
this.hideInstallPrompts();
this.saveInstallPreference('accepted', true);
this.saveInstallPreference('installed', true);
} else {
console.log('❌ User dismissed install prompt');
this.handleInstallDismissal();
}
@@ -432,14 +397,12 @@ class PWAInstallPrompt {
gotItBtn.addEventListener('click', () => {
modal.remove();
this.saveInstallPreference('ios_instructions_shown', Date.now());
console.log('✅ iOS install instructions acknowledged');
});
closeBtn.addEventListener('click', () => {
modal.remove();
this.dismissedCount++;
this.saveInstallPreference('dismissed', this.dismissedCount);
console.log('❌ iOS install instructions dismissed');
});
document.body.appendChild(modal);
@@ -484,14 +447,12 @@ class PWAInstallPrompt {
const closeBtn = modal.querySelector('.close-btn');
closeBtn.addEventListener('click', () => {
modal.remove();
console.log('📱 Fallback install instructions closed');
});
document.body.appendChild(modal);
}
showInstallSuccess() {
console.log('✅ Showing installation success notification');
const notification = document.createElement('div');
notification.className = 'fixed top-4 right-4 bg-green-500 text-white p-4 rounded-lg shadow-lg z-50 max-w-sm transform translate-x-full transition-transform duration-300';
@@ -528,14 +489,12 @@ class PWAInstallPrompt {
shouldShowPrompt() {
if (this.checkInstallationStatus()) {
console.log('💿 App is installed, not showing prompt');
return false;
}
const preferences = this.loadInstallPreferences();
if (preferences.installed) {
console.log('💿 Installation preference found, marking as installed');
this.isInstalled = true;
this.hideInstallPrompts();
return false;
@@ -566,8 +525,6 @@ class PWAInstallPrompt {
this.hideInstallPrompts();
this.saveInstallPreference('dismissed', this.dismissedCount);
console.log(`💿 Install prompt dismissed (${this.dismissedCount}/${this.maxDismissals})`);
// Show encouraging message on final dismissal
if (this.dismissedCount >= this.maxDismissals) {
this.showFinalDismissalMessage();
@@ -610,7 +567,6 @@ class PWAInstallPrompt {
const okBtn = notification.querySelector('.ok-btn');
okBtn.addEventListener('click', () => {
notification.remove();
console.log('✅ Final dismissal message acknowledged');
});
document.body.appendChild(notification);
@@ -632,7 +588,6 @@ class PWAInstallPrompt {
try {
localStorage.setItem('pwa_install_prefs', JSON.stringify(preferences));
console.log('💾 Install preference saved:', action, value);
} catch (error) {
console.warn('⚠️ Could not save install preferences:', error);
}
@@ -661,10 +616,6 @@ class PWAInstallPrompt {
// Public API methods
showInstallPrompt() {
if (this.checkInstallationStatus()) {
console.log('💿 App already installed, not showing prompt');
return;
}
if (this.isIOSSafari()) {
this.showIOSInstallInstructions();
@@ -694,17 +645,14 @@ class PWAInstallPrompt {
resetDismissals() {
this.dismissedCount = 0;
this.saveInstallPreference('dismissed', 0);
console.log('💿 Install dismissals reset');
}
// Method for setting service worker registration
setServiceWorkerRegistration(registration) {
this.swRegistration = registration;
console.log('📡 Service Worker registration set for PWA Install Prompt');
}
forceInstallationCheck() {
console.log('🔄 Force checking installation status...');
this.installationChecked = false;
const wasInstalled = this.isInstalled;
const isNowInstalled = this.checkInstallationStatus();
+4 -23
View File
@@ -49,7 +49,6 @@ class PWAOfflineManager {
}
async init() {
console.log('📴 PWA Offline Manager initializing...');
try {
// Initialize offline database
@@ -74,8 +73,7 @@ class PWAOfflineManager {
if (this.isOnline) {
await this.processOfflineQueue();
}
console.log('✅ PWA Offline Manager initialized');
} catch (error) {
console.error('❌ Offline Manager initialization failed:', error);
@@ -97,7 +95,6 @@ class PWAOfflineManager {
request.onsuccess = () => {
this.offlineDB = request.result;
console.log('💾 Offline database opened successfully');
resolve(this.offlineDB);
};
@@ -107,7 +104,6 @@ class PWAOfflineManager {
// Create object stores
Object.entries(this.dbConfig.stores).forEach(([storeName, config]) => {
if (!db.objectStoreNames.contains(storeName)) {
console.log(`📦 Creating object store: ${storeName}`);
const store = db.createObjectStore(storeName, {
keyPath: config.keyPath,
@@ -129,7 +125,6 @@ class PWAOfflineManager {
setupEventListeners() {
// Network status changes
window.addEventListener('online', () => {
console.log('🌐 Connection restored');
this.isOnline = true;
this.reconnectAttempts = 0;
this.updateConnectionStatus(true);
@@ -137,7 +132,6 @@ class PWAOfflineManager {
});
window.addEventListener('offline', () => {
console.log('📴 Connection lost');
this.isOnline = false;
this.updateConnectionStatus(false);
this.handleConnectionLost();
@@ -320,7 +314,6 @@ class PWAOfflineManager {
}
this.reconnectAttempts++;
console.log(`🔄 Reconnection attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts}`);
// Try to detect if we're actually back online
this.checkOnlineStatus();
@@ -328,7 +321,6 @@ class PWAOfflineManager {
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
clearInterval(this.reconnectInterval);
this.reconnectInterval = null;
console.log('❌ Max reconnection attempts reached');
}
}, 10000); // Try every 10 seconds
}
@@ -343,8 +335,6 @@ class PWAOfflineManager {
});
if (response.ok && !this.isOnline) {
// We're actually online but navigator.onLine is wrong
console.log('🌐 Detected online status, updating...');
this.isOnline = true;
this.handleConnectionRestored();
}
@@ -374,8 +364,7 @@ class PWAOfflineManager {
const transaction = this.offlineDB.transaction(['offlineQueue'], 'readwrite');
const store = transaction.objectStore('offlineQueue');
await this.promisifyRequest(store.add(queueItem));
console.log('📤 Action queued for offline sync:', action.type);
this.offlineQueue.push(queueItem);
// Try to register background sync
@@ -395,7 +384,6 @@ class PWAOfflineManager {
}
this.syncInProgress = true;
console.log('🔄 Processing offline queue...');
let processedCount = 0;
let errorCount = 0;
@@ -420,7 +408,6 @@ class PWAOfflineManager {
await this.processQueueItem(item);
await this.promisifyRequest(store.delete(item.id));
processedCount++;
console.log('✅ Processed offline action:', item.type);
} catch (error) {
console.error('❌ Failed to process offline action:', error);
errorCount++;
@@ -575,7 +562,6 @@ class PWAOfflineManager {
const savedConnectionState = await this.getStoredData('sessionData', 'connection_state');
if (savedConnectionState && savedConnectionState.wasConnected) {
console.log('🔄 Attempting WebRTC reconnection...');
// Show reconnection indicator
this.showReconnectionIndicator();
@@ -681,8 +667,7 @@ class PWAOfflineManager {
const transaction = this.offlineDB.transaction(['appState'], 'readwrite');
const store = transaction.objectStore('appState');
await this.promisifyRequest(store.put(appState));
console.log('💾 Application state saved for offline recovery');
} catch (error) {
console.error('❌ Failed to save application state:', error);
}
@@ -743,8 +728,7 @@ class PWAOfflineManager {
} else {
await this.promisifyRequest(store.clear());
}
console.log(`🗑️ Cleared stored data from ${storeName}`);
} catch (error) {
console.error(`❌ Failed to clear stored data from ${storeName}:`, error);
}
@@ -754,7 +738,6 @@ class PWAOfflineManager {
if ('serviceWorker' in navigator && 'sync' in window.ServiceWorkerRegistration.prototype) {
navigator.serviceWorker.ready.then(registration => {
this.registration = registration;
console.log('📡 Background sync registered');
});
} else {
console.warn('⚠️ Background sync not supported');
@@ -812,7 +795,6 @@ class PWAOfflineManager {
}
handleOfflineDisconnection(details) {
console.log('🔌 WebRTC disconnected while offline:', details);
// Save connection state for recovery
this.storeData('sessionData', {
@@ -857,7 +839,6 @@ class PWAOfflineManager {
}
handleNetworkFailure(error) {
console.log('🌐 Network failure detected:', error?.message);
// Queue the failed action for retry if appropriate
if (this.shouldQueueFailedRequest(error)) {