refactor: add AuthGuard component and fix API client empty response handling
- Add reusable AuthGuard component for protected routes - Move auth logic from index.tsx to (tabs)/_layout.tsx via AuthGuard - Fix ApiClient to handle empty responses (204 No Content) - Use useFocusEffect in chat.tsx to load messages after auth is ready - Extract getDateKey() helper function in calendar.tsx
This commit is contained in:
@@ -55,7 +55,12 @@ async function request<T>(
|
||||
}
|
||||
|
||||
apiLogger.debug(`${method} ${endpoint} - ${response.status} (${duration}ms)`);
|
||||
return response.json();
|
||||
|
||||
const text = await response.text();
|
||||
if (!text) {
|
||||
return undefined as T;
|
||||
}
|
||||
return JSON.parse(text);
|
||||
} catch (error) {
|
||||
const duration = Math.round(performance.now() - start);
|
||||
apiLogger.error(`${method} ${endpoint} failed (${duration}ms): ${error}`);
|
||||
|
||||
Reference in New Issue
Block a user