From 822f0e9f33b8711ac8a8b656a4778b7404a37e0b Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Sun, 7 Sep 2025 19:35:19 +0200 Subject: Remove timeouts that shouldn't be there --- src/frontend/app/components/StopSheet.tsx | 25 +++++++++++-------------- src/frontend/app/routes/estimates-$id.tsx | 6 ------ 2 files changed, 11 insertions(+), 20 deletions(-) (limited to 'src/frontend/app') diff --git a/src/frontend/app/components/StopSheet.tsx b/src/frontend/app/components/StopSheet.tsx index e8000d1..702c574 100644 --- a/src/frontend/app/components/StopSheet.tsx +++ b/src/frontend/app/components/StopSheet.tsx @@ -23,19 +23,16 @@ interface ErrorInfo { } const loadStopData = async (stopId: number): Promise => { - // Add delay to see skeletons in action (remove in production) - await new Promise(resolve => setTimeout(resolve, 1000)); - const resp = await fetch(`/api/GetStopEstimates?id=${stopId}`, { headers: { Accept: "application/json", }, }); - + if (!resp.ok) { throw new Error(`HTTP ${resp.status}: ${resp.statusText}`); } - + return await resp.json(); }; @@ -55,17 +52,17 @@ export const StopSheet: React.FC = ({ if (!navigator.onLine) { return { type: 'network', message: 'No internet connection' }; } - + if (error.message?.includes('Failed to fetch') || error.message?.includes('NetworkError')) { return { type: 'network' }; } - + if (error.message?.includes('HTTP')) { const statusMatch = error.message.match(/HTTP (\d+):/); const status = statusMatch ? parseInt(statusMatch[1]) : undefined; return { type: 'server', status }; } - + return { type: 'unknown', message: error.message }; }; @@ -74,7 +71,7 @@ export const StopSheet: React.FC = ({ setLoading(true); setError(null); setData(null); - + const stopData = await loadStopData(stopId); setData(stopData); setLastUpdated(new Date()); @@ -138,8 +135,8 @@ export const StopSheet: React.FC = ({ {loading ? ( ) : error ? ( - = ({ })} )} - +
- - + => { - // Add delay to see skeletons in action (remove in production) - await new Promise(resolve => setTimeout(resolve, 1000)); - const resp = await fetch(`/api/GetStopEstimates?id=${stopId}`, { headers: { Accept: "application/json", @@ -53,9 +50,6 @@ const loadData = async (stopId: string): Promise => { }; const loadTimetableData = async (stopId: string): Promise => { - // Add delay to see skeletons in action (remove in production) - await new Promise(resolve => setTimeout(resolve, 1500)); - const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD format const resp = await fetch(`/api/GetStopTimetable?date=${today}&stopId=${stopId}`, { headers: { -- cgit v1.3