Skip to content

Commit 4d36450

Browse files
Fix: Reduce loading time
Removed the 3-second timeout in `AuthContext.tsx` as the page still loads slowly.
1 parent b58f31b commit 4d36450

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/contexts/AuthContext.tsx

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

2626
useEffect(() => {
27-
console.log('🔐 AuthProvider - Initialisation RAPIDE');
27+
console.log('🔐 AuthProvider - Initialisation ULTRA-RAPIDE');
2828

29-
// Pas de cache localStorage qui ralentit - Firebase est assez rapide
29+
// Timeout très court : si Firebase met plus d'1 seconde, on affiche l'interface
30+
const quickTimeoutId = setTimeout(() => {
31+
console.log('🔐 Timeout 1s atteint - affichage immédiat de l\'interface');
32+
setLoading(false);
33+
}, 1000);
34+
3035
const unsubscribe = onAuthStateChanged(auth, (user) => {
3136
console.log('🔐 Firebase Auth state changed:', user ? 'CONNECTÉ' : 'DÉCONNECTÉ');
3237
setUser(user);
33-
setLoading(false); // AUTH TERMINÉE - Interface peut s'afficher
38+
setLoading(false);
39+
clearTimeout(quickTimeoutId); // On annule le timeout si Firebase répond
3440

3541
if (user) {
3642
console.log('🔐 Utilisateur authentifié:', user.uid);
@@ -39,15 +45,9 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
3945
}
4046
});
4147

42-
// Timeout de sécurité : si Firebase met plus de 3 secondes, on affiche quand même l'interface
43-
const timeoutId = setTimeout(() => {
44-
console.log('🔐 Timeout atteint - affichage forcé de l\'interface');
45-
setLoading(false);
46-
}, 3000);
47-
4848
return () => {
4949
unsubscribe();
50-
clearTimeout(timeoutId);
50+
clearTimeout(quickTimeoutId);
5151
};
5252
}, []);
5353

0 commit comments

Comments
 (0)