diff --git a/src/App.js b/src/App.js index 19877c8..c60d3e2 100644 --- a/src/App.js +++ b/src/App.js @@ -1,8 +1,8 @@ -import React, { useState, useEffect, useRef } from 'react'; // Added useRef +import React, { useState, useEffect, useRef } from 'react'; import { initializeApp } from 'firebase/app'; import { getAuth, signInAnonymously, onAuthStateChanged, signInWithCustomToken } from 'firebase/auth'; -import { getFirestore, doc, setDoc, addDoc, getDoc, getDocs, collection, onSnapshot, updateDoc, deleteDoc, query, writeBatch } from 'firebase/firestore'; // Removed where as it's not used -import { ArrowLeft, PlusCircle, Users, Swords, Shield, Trash2, Eye, Edit3, Save, XCircle, ChevronsUpDown, ChevronDown, ChevronUp, UserCheck, UserX, HeartCrack, HeartPulse, Zap, Share2, Copy as CopyIcon } from 'lucide-react'; +import { getFirestore, doc, setDoc, addDoc, getDoc, getDocs, collection, onSnapshot, updateDoc, deleteDoc, query, writeBatch } from 'firebase/firestore'; +import { ArrowLeft, PlusCircle, Users, Swords, Shield, Trash2, Eye, Edit3, Save, XCircle, ChevronsUpDown, ChevronDown, ChevronUp, UserCheck, UserX, HeartCrack, HeartPulse, Zap, Share2, Copy as CopyIcon, Image as ImageIcon, EyeOff } from 'lucide-react'; // --- Firebase Configuration --- const firebaseConfig = { @@ -24,7 +24,6 @@ const missingKeys = requiredFirebaseConfigKeys.filter(key => !firebaseConfig[key if (missingKeys.length > 0) { console.error(`CRITICAL: Missing Firebase config values from environment variables: ${missingKeys.join(', ')}`); console.error("Firebase cannot be initialized. Please ensure all REACT_APP_FIREBASE_... variables are set in your .env.local file and accessible during the build."); - // Fallback: Render a message or allow app to break if Firebase is critical } else { try { app = initializeApp(firebaseConfig); @@ -32,11 +31,9 @@ if (missingKeys.length > 0) { auth = getAuth(app); } catch (error) { console.error("Error initializing Firebase:", error); - // Handle initialization error, perhaps by setting db and auth to null or showing an error UI } } - // --- Firestore Paths --- const APP_ID = process.env.REACT_APP_TRACKER_APP_ID || 'ttrpg-initiative-tracker-default'; const PUBLIC_DATA_PATH = `artifacts/${APP_ID}/public/data`; @@ -60,10 +57,10 @@ function App() { const [directDisplayParams, setDirectDisplayParams] = useState(null); useEffect(() => { - if (!auth) { // Check if Firebase auth was initialized + if (!auth) { setError("Firebase Auth not initialized. Check your Firebase configuration."); setIsLoading(false); - setIsAuthReady(false); // Explicitly set auth not ready + setIsAuthReady(false); return; } const handleHashChange = () => { @@ -109,7 +106,7 @@ function App() { }; }, []); - if (!db || !auth) { // If Firebase failed to init + if (!db || !auth) { return (
Authenticating...
} {/* Show auth message only if no other error */} + {!isAuthReady && !error &&Authenticating...
} {!directDisplayParams && ( )}ID: {campaign.id}
+ {campaign.playerDisplayBackgroundUrl &&