Skip to content

Commit 40afa55

Browse files
Fix: Slow initial loading
Reduce initial loading time by removing unnecessary code.
1 parent d090aa3 commit 40afa55

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

src/contexts/AuthContext.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,43 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
2424
const [loading, setLoading] = useState(true);
2525

2626
useEffect(() => {
27-
console.log('🔐 AuthProvider - Démarrage simple');
27+
console.log('🔐 AuthProvider - Démarrage ULTRA-RAPIDE');
28+
29+
// Timeout de 500ms maximum pour éviter les blocages
30+
const quickTimeout = setTimeout(() => {
31+
console.log('🔐 TIMEOUT 500ms - affichage immédiat');
32+
setLoading(false);
33+
}, 500);
2834

2935
const unsubscribe = onAuthStateChanged(auth, (user) => {
30-
console.log('🔐 Auth state:', user ? 'CONNECTÉ' : 'DÉCONNECTÉ');
36+
console.log('🔐 Auth state reçu:', user ? 'CONNECTÉ' : 'DÉCONNECTÉ');
37+
clearTimeout(quickTimeout);
3138
setUser(user);
3239
setLoading(false);
3340
}, (error) => {
3441
console.error('🚨 Erreur Auth:', error);
42+
clearTimeout(quickTimeout);
3543
setLoading(false);
3644
});
3745

38-
return unsubscribe;
46+
return () => {
47+
clearTimeout(quickTimeout);
48+
unsubscribe();
49+
};
3950
}, []);
4051

4152
const signInWithEmail = async (email: string, password: string) => {
42-
console.log('🔐 Connexion email simple...');
53+
console.log('🔐 Connexion email...');
4354
return await signInWithEmailAndPassword(auth, email, password);
4455
};
4556

4657
const signUpWithEmail = async (email: string, password: string) => {
47-
console.log('🔐 Création compte simple...');
58+
console.log('🔐 Création compte...');
4859
return await createUserWithEmailAndPassword(auth, email, password);
4960
};
5061

5162
const signInWithGoogle = async () => {
52-
console.log('🔐 Connexion Google simple...');
63+
console.log('🔐 Connexion Google...');
5364
return await signInWithPopup(auth, googleProvider);
5465
};
5566

0 commit comments

Comments
 (0)