({
src,
basePath = lottieAssetsBasePath,
}: {
src: string;
basePath?: string;
})
| 5 | export const lottieAssetsBasePath = '/app/assets/lottie'; |
| 6 | |
| 7 | export const lottieAnimationQueryOptions = ({ |
| 8 | src, |
| 9 | basePath = lottieAssetsBasePath, |
| 10 | }: { |
| 11 | src: string; |
| 12 | basePath?: string; |
| 13 | }) => { |
| 14 | return { |
| 15 | queryKey: generateQueryKey( |
| 16 | RequestKey.LottieAnimations, |
| 17 | undefined, |
| 18 | basePath, |
| 19 | src, |
| 20 | ), |
| 21 | queryFn: async () => { |
| 22 | const animationPath = `${basePath}${src}`; |
| 23 | |
| 24 | const headers = new Headers(); |
| 25 | headers.set('Accept', 'application/json'); |
| 26 | |
| 27 | const response = await fetch(fromCDN(animationPath), { |
| 28 | headers, |
| 29 | cache: 'force-cache', |
| 30 | }); |
| 31 | |
| 32 | if (!response.ok) { |
| 33 | throw new Error(`Failed to load animation from ${animationPath}`); |
| 34 | } |
| 35 | |
| 36 | const result = await response.json(); |
| 37 | |
| 38 | return result; |
| 39 | }, |
| 40 | ...disabledRefetch, |
| 41 | staleTime: Infinity, |
| 42 | gcTime: Infinity, |
| 43 | }; |
| 44 | }; |
no test coverage detected