From e843acdf8af1e464ced51d80107e725d2b18bd4f Mon Sep 17 00:00:00 2001 From: david raistrick <1108844+keen99@users.noreply.github.com> Date: Mon, 29 Jun 2026 12:03:57 -0400 Subject: [PATCH] Revert "M2: gate storage init on STORAGE mode (firebase vs ws/memory)" This reverts commit 3e84f2832521a878c35523c0e3ddf5af71bbb47f. --- src/App.js | 63 +++++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/src/App.js b/src/App.js index a460536..9e78de7 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,7 @@ import React, { useState, useEffect, useRef, useMemo } from 'react'; import { initializeApp } from './storage'; import { getAuth, signInAnonymously, onAuthStateChanged, signInWithCustomToken } from './storage'; -import { getFirestore, doc, setDoc, addDoc, collection, onSnapshot, updateDoc, deleteDoc, query, orderBy, limit, writeBatch, getStorage, getStorageMode } from './storage'; +import { getFirestore, doc, setDoc, addDoc, collection, onSnapshot, updateDoc, deleteDoc, query, orderBy, limit, writeBatch, getStorage } from './storage'; import { PlusCircle, Users, Swords, Trash2, Eye, Edit3, Save, XCircle, ChevronsUpDown, UserCheck, UserX, HeartCrack, HeartPulse, Zap, EyeOff, ExternalLink, AlertTriangle, @@ -97,40 +97,29 @@ let db; let auth; let storage; -const STORAGE_MODE = getStorageMode(); +// Initialize Firebase +const initializeFirebase = () => { + const requiredKeys = ['apiKey', 'authDomain', 'projectId', 'appId']; + const missingKeys = requiredKeys.filter(key => !firebaseConfig[key]); -// Initialize storage backend. firebase mode = real SDK init. -// ws/memory mode = mock auth, no firebase. -const initializeStorage = () => { - if (STORAGE_MODE === 'firebase') { - const requiredKeys = ['apiKey', 'authDomain', 'projectId', 'appId']; - const missingKeys = requiredKeys.filter(key => !firebaseConfig[key]); - if (missingKeys.length > 0) { - console.error(`CRITICAL: Missing Firebase config values: ${missingKeys.join(', ')}`); - return false; - } - try { - app = initializeApp(firebaseConfig); - db = getFirestore(app); - auth = getAuth(app); - storage = getStorage(); - return true; - } catch (error) { - console.error("Error initializing Firebase:", error); - return false; - } + if (missingKeys.length > 0) { + console.error(`CRITICAL: Missing Firebase config values: ${missingKeys.join(', ')}`); + return false; } - // ws / memory mode: stub auth so App's anon-sign-in path works. - const FAKE_USER = { uid: 'local-user', isAnonymous: true }; - auth = { - currentUser: FAKE_USER, - }; - storage = getStorage(); - return true; + try { + app = initializeApp(firebaseConfig); + db = getFirestore(app); + auth = getAuth(app); + storage = getStorage(); + return true; + } catch (error) { + console.error("Error initializing Firebase:", error); + return false; + } }; -const isInitialized = initializeStorage(); +const isFirebaseInitialized = initializeFirebase(); // ============================================================================ // FIRESTORE PATH HELPERS @@ -2815,20 +2804,12 @@ function App() { } if (!auth) { - setError("Auth not initialized."); + setError("Firebase Auth not initialized. Check your Firebase configuration."); setIsLoading(false); setIsAuthReady(false); return; } - // ws/memory mode: stub auth, no SDK sign-in. Unblock UI immediately. - if (STORAGE_MODE !== 'firebase') { - setUserId(auth.currentUser?.uid || 'local-user'); - setIsAuthReady(true); - setIsLoading(false); - return; - } - const initAuth = async () => { try { const token = window.__initial_auth_token; @@ -2862,11 +2843,11 @@ function App() { return () => unsubscribe(); }, []); - if (!isInitialized || !auth) { + if (!isFirebaseInitialized || !db || !auth) { return ( ); }