Mobile Work

This commit is contained in:
Eric Gullickson
2025-09-19 11:33:31 -05:00
parent 040da4c759
commit 3588372cef
7 changed files with 189 additions and 13 deletions

View File

@@ -23,6 +23,15 @@ export const useVehicles = () => {
queryKey: ['vehicles'],
queryFn: vehiclesApi.getAll,
enabled: isAuthenticated && !isLoading,
retry: (failureCount, error: any) => {
// Retry 401 errors up to 3 times for mobile auth timing issues
if (error?.response?.status === 401 && failureCount < 3) {
console.log(`[Mobile Auth] API retry ${failureCount + 1}/3 for 401 error`);
return true;
}
return false;
},
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
});
};
@@ -32,6 +41,15 @@ export const useVehicle = (id: string) => {
queryKey: ['vehicles', id],
queryFn: () => vehiclesApi.getById(id),
enabled: !!id && isAuthenticated && !isLoading,
retry: (failureCount, error: any) => {
// Retry 401 errors up to 3 times for mobile auth timing issues
if (error?.response?.status === 401 && failureCount < 3) {
console.log(`[Mobile Auth] API retry ${failureCount + 1}/3 for 401 error`);
return true;
}
return false;
},
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
});
};