Add global QueryErrorResetBoundary wrapping the app so TanStack Query errors are caught with a retry UI instead of crashing. Enable throwOnError in QueryClient defaults. Update ListingMap to use real latitude/longitude from API when available, falling back to city-based jitter for listings without coordinates. Co-Authored-By: Paperclip <noreply@paperclip.ing>
34 lines
726 B
TypeScript
34 lines
726 B
TypeScript
'use client';
|
|
|
|
import { QueryClient } from '@tanstack/react-query';
|
|
|
|
function makeQueryClient() {
|
|
return new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
staleTime: 60 * 1000,
|
|
gcTime: 5 * 60 * 1000,
|
|
retry: 3,
|
|
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
|
|
refetchOnWindowFocus: false,
|
|
throwOnError: true,
|
|
},
|
|
mutations: {
|
|
retry: 1,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
let browserQueryClient: QueryClient | undefined;
|
|
|
|
export function getQueryClient() {
|
|
if (typeof window === 'undefined') {
|
|
return makeQueryClient();
|
|
}
|
|
if (!browserQueryClient) {
|
|
browserQueryClient = makeQueryClient();
|
|
}
|
|
return browserQueryClient;
|
|
}
|