151 lines
6.6 KiB
Markdown
151 lines
6.6 KiB
Markdown
|
|
# LOGS ESPECÍFICOS IMPLEMENTADOS - TODOS OS OUTROS LOGS DESABILITADOS
|
||
|
|
|
||
|
|
## ✅ **LOGS DESABILITADOS COM SUCESSO**
|
||
|
|
|
||
|
|
Todos os logs que não tenham o prefixo `🚨` foram comentados para focar apenas no problema específico de navegação após login.
|
||
|
|
|
||
|
|
## 🚨 **LOGS ATIVOS (APENAS ESTES)**
|
||
|
|
|
||
|
|
### **1. Navigation Context (`src/navigation/index.tsx`)**
|
||
|
|
```typescript
|
||
|
|
console.log('🚨 NAVIGATION DEBUG - ESTADO ATUAL:');
|
||
|
|
console.log('🚨 isLoading:', isLoading);
|
||
|
|
console.log('🚨 user:', user ? 'Logado' : 'Não logado');
|
||
|
|
console.log('🚨 isInitialDataLoaded:', isInitialDataLoaded);
|
||
|
|
console.log('🚨 forceInitialLoad:', forceInitialLoad);
|
||
|
|
console.log('🚨 DECISÃO DE NAVEGAÇÃO:');
|
||
|
|
console.log('🚨 ✅ DECISÃO: MOSTRANDO InitialDataLoadScreen');
|
||
|
|
console.log('🚨 ❌ DECISÃO: MOSTRANDO Main/TabNavigator');
|
||
|
|
console.log('🚨 NAVIGATION RENDER - ESTADO FINAL:');
|
||
|
|
console.log('🚨 TELA QUE SERÁ RENDERIZADA:', ...);
|
||
|
|
```
|
||
|
|
|
||
|
|
### **2. OfflineMode Context (`src/contexts/OfflineModeContext.tsx`)**
|
||
|
|
```typescript
|
||
|
|
console.log('🚨 OFFLINE CONTEXT - MONTANDO CONTEXTO');
|
||
|
|
console.log('🚨 Estado inicial: isInitialDataLoaded=false, forceInitialLoad=true');
|
||
|
|
console.log('🚨 OFFLINE CONTEXT - ESTADOS DEFINIDOS');
|
||
|
|
console.log('🚨 isInitialDataLoaded: false');
|
||
|
|
console.log('🚨 forceInitialLoad: true');
|
||
|
|
console.log('🚨 OFFLINE CONTEXT - VERIFICANDO STATUS INICIAL');
|
||
|
|
console.log('🚨 Forçando: isInitialDataLoaded=false, forceInitialLoad=true');
|
||
|
|
console.log('🚨 OFFLINE CONTEXT - STATUS CONFIRMADO');
|
||
|
|
console.log('🚨 OFFLINE CONTEXT - INICIANDO CARGA DE DADOS');
|
||
|
|
console.log('🚨 OFFLINE CONTEXT - CARGA CONCLUÍDA COM SUCESSO');
|
||
|
|
console.log('🚨 isInitialDataLoaded: true');
|
||
|
|
console.log('🚨 forceInitialLoad: false');
|
||
|
|
```
|
||
|
|
|
||
|
|
### **3. Auth Context (`src/contexts/AuthContext.tsx`)**
|
||
|
|
```typescript
|
||
|
|
console.log('🚨 AUTH CONTEXT - INICIANDO LOGIN');
|
||
|
|
console.log('🚨 Usuário:', username);
|
||
|
|
console.log('🚨 AUTH CONTEXT - LIMPANDO BASE SQLite');
|
||
|
|
console.log('🚨 AUTH CONTEXT - RESETANDO MODO OFFLINE');
|
||
|
|
console.log('🚨 AUTH CONTEXT - BASE SQLite LIMPA');
|
||
|
|
console.log('🚨 AUTH CONTEXT - FAZENDO LOGIN NA API');
|
||
|
|
console.log('🚨 AUTH CONTEXT - LOGIN BEM-SUCEDIDO');
|
||
|
|
console.log('🚨 AUTH CONTEXT - VERIFICANDO ROTEIRIZAÇÃO');
|
||
|
|
console.log('🚨 AUTH CONTEXT - Entregas carregadas:', deliveries.length);
|
||
|
|
console.log('🚨 AUTH CONTEXT - Precisa de roteirização?', needsRouting);
|
||
|
|
console.log('🚨 AUTH CONTEXT - LOGIN FINALIZADO');
|
||
|
|
```
|
||
|
|
|
||
|
|
### **4. Deliveries Context (`src/contexts/DeliveriesContext.tsx`)**
|
||
|
|
```typescript
|
||
|
|
console.log("🚨 DELIVERIES CONTEXT - VERIFICANDO CARREGAMENTO AUTOMÁTICO")
|
||
|
|
console.log("🚨 isInitialDataLoaded:", isInitialDataLoaded)
|
||
|
|
console.log("🚨 hasInitializedRef.current:", hasInitializedRef.current)
|
||
|
|
console.log("🚨 DELIVERIES CONTEXT - CARREGANDO DADOS LOCAIS")
|
||
|
|
console.log("🚨 DELIVERIES CONTEXT - INICIANDO CARREGAMENTO")
|
||
|
|
console.log("🚨 Force refresh:", forceRefresh)
|
||
|
|
console.log("🚨 isInitialDataLoaded:", isInitialDataLoaded)
|
||
|
|
console.log("🚨 isOfflineMode:", isOfflineMode)
|
||
|
|
console.log("🚨 DELIVERIES CONTEXT - USANDO DADOS LOCAIS")
|
||
|
|
console.log("🚨 DELIVERIES CONTEXT - Dados locais carregados:", data.length, "entregas")
|
||
|
|
console.log("🚨 DELIVERIES CONTEXT - CARREGANDO DA API")
|
||
|
|
console.log("🚨 DELIVERIES CONTEXT - Total de entregas:", data.length)
|
||
|
|
```
|
||
|
|
|
||
|
|
## 🔇 **LOGS DESABILITADOS (COMENTADOS)**
|
||
|
|
|
||
|
|
### **Todos os logs sem prefixo `🚨` foram comentados:**
|
||
|
|
|
||
|
|
- `console.log("=== DEBUG: NAVIGATION STATE ===")` → `// console.log(...)`
|
||
|
|
- `console.log("=== 🔄 CONTEXTO OFFLINE MONTADO ===")` → `// console.log(...)`
|
||
|
|
- `console.log("=== 🔐 DEBUG: INICIANDO PROCESSO DE LOGIN ===")` → `// console.log(...)`
|
||
|
|
- `console.log("=== DELIVERIES CONTEXT: VERIFICANDO ===")` → `// console.log(...)`
|
||
|
|
- `console.error("❌ Erro ao verificar status inicial:", error)` → `// console.error(...)`
|
||
|
|
- `console.log("📸 Uploads de fotos processados após volta online")` → `// console.log(...)`
|
||
|
|
- `console.log("✅ Estado atualizado com as entregas ordenadas")` → `// console.log(...)`
|
||
|
|
- E todos os outros logs não relacionados ao problema específico
|
||
|
|
|
||
|
|
## 🎯 **FLUXO ESPERADO DOS LOGS**
|
||
|
|
|
||
|
|
### **✅ Primeiro Login (Funcionando):**
|
||
|
|
```
|
||
|
|
🚨 AUTH CONTEXT - INICIANDO LOGIN
|
||
|
|
🚨 AUTH CONTEXT - LIMPANDO BASE SQLite
|
||
|
|
🚨 AUTH CONTEXT - RESETANDO MODO OFFLINE
|
||
|
|
🚨 AUTH CONTEXT - BASE SQLite LIMPA
|
||
|
|
🚨 AUTH CONTEXT - FAZENDO LOGIN NA API
|
||
|
|
🚨 AUTH CONTEXT - LOGIN BEM-SUCEDIDO
|
||
|
|
🚨 AUTH CONTEXT - VERIFICANDO ROTEIRIZAÇÃO
|
||
|
|
🚨 AUTH CONTEXT - Entregas carregadas: X
|
||
|
|
🚨 AUTH CONTEXT - Precisa de roteirização? false
|
||
|
|
🚨 AUTH CONTEXT - LOGIN FINALIZADO
|
||
|
|
|
||
|
|
🚨 OFFLINE CONTEXT - MONTANDO CONTEXTO
|
||
|
|
🚨 Estado inicial: isInitialDataLoaded=false, forceInitialLoad=true
|
||
|
|
🚨 OFFLINE CONTEXT - ESTADOS DEFINIDOS
|
||
|
|
🚨 isInitialDataLoaded: false
|
||
|
|
🚨 forceInitialLoad: true
|
||
|
|
|
||
|
|
🚨 NAVIGATION DEBUG - ESTADO ATUAL:
|
||
|
|
🚨 user: Logado
|
||
|
|
🚨 isInitialDataLoaded: false
|
||
|
|
🚨 forceInitialLoad: true
|
||
|
|
🚨 ✅ DECISÃO: MOSTRANDO InitialDataLoadScreen
|
||
|
|
```
|
||
|
|
|
||
|
|
### **❌ Segundo Login (Problemático):**
|
||
|
|
```
|
||
|
|
🚨 AUTH CONTEXT - INICIANDO LOGIN
|
||
|
|
🚨 AUTH CONTEXT - LIMPANDO BASE SQLite
|
||
|
|
🚨 AUTH CONTEXT - RESETANDO MODO OFFLINE
|
||
|
|
🚨 AUTH CONTEXT - BASE SQLite LIMPA
|
||
|
|
🚨 AUTH CONTEXT - FAZENDO LOGIN NA API
|
||
|
|
🚨 AUTH CONTEXT - LOGIN BEM-SUCEDIDO
|
||
|
|
🚨 AUTH CONTEXT - VERIFICANDO ROTEIRIZAÇÃO
|
||
|
|
🚨 AUTH CONTEXT - Entregas carregadas: X
|
||
|
|
🚨 AUTH CONTEXT - Precisa de roteirização? false
|
||
|
|
🚨 AUTH CONTEXT - LOGIN FINALIZADO
|
||
|
|
|
||
|
|
🚨 OFFLINE CONTEXT - MONTANDO CONTEXTO
|
||
|
|
🚨 Estado inicial: isInitialDataLoaded=false, forceInitialLoad=true
|
||
|
|
🚨 OFFLINE CONTEXT - ESTADOS DEFINIDOS
|
||
|
|
🚨 isInitialDataLoaded: false
|
||
|
|
🚨 forceInitialLoad: true
|
||
|
|
|
||
|
|
// MAS DEPOIS ALGUM LUGAR MUDA PARA:
|
||
|
|
🚨 NAVIGATION DEBUG - ESTADO ATUAL:
|
||
|
|
🚨 user: Logado
|
||
|
|
🚨 isInitialDataLoaded: true ← PROBLEMA AQUI!
|
||
|
|
🚨 forceInitialLoad: false ← PROBLEMA AQUI!
|
||
|
|
🚨 ❌ DECISÃO: MOSTRANDO Main/TabNavigator
|
||
|
|
```
|
||
|
|
|
||
|
|
## 🧪 **COMO TESTAR**
|
||
|
|
|
||
|
|
1. **Fazer Login** com qualquer usuário
|
||
|
|
2. **Verificar Logs** - deve mostrar apenas logs com `🚨`
|
||
|
|
3. **Fazer Logout e Login Novamente** - processo deve repetir
|
||
|
|
4. **Verificar Logs** - deve mostrar `🚨 ✅ DECISÃO: MOSTRANDO InitialDataLoadScreen` novamente
|
||
|
|
5. **Se mostrar `🚨 ❌ DECISÃO: MOSTRANDO Main/TabNavigator`** - identificar onde os estados estão sendo alterados
|
||
|
|
|
||
|
|
## 🎯 **OBJETIVO**
|
||
|
|
|
||
|
|
Agora os logs estão **100% focados** no problema específico. Apenas logs com prefixo `🚨` serão exibidos, facilitando a identificação exata de onde e quando os estados `isInitialDataLoaded` e `forceInitialLoad` estão sendo alterados incorretamente no segundo login.
|
||
|
|
|
||
|
|
**Todos os outros logs foram desabilitados com sucesso!** 🚀
|