MCPcopy Create free account
hub / github.com/dailydotdev/apps / lottieAnimationQueryOptions

Function lottieAnimationQueryOptions

packages/shared/src/lib/lottie.ts:7–44  ·  view source on GitHub ↗
({
  src,
  basePath = lottieAssetsBasePath,
}: {
  src: string;
  basePath?: string;
})

Source from the content-addressed store, hash-verified

5export const lottieAssetsBasePath = '/app/assets/lottie';
6
7export 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};

Callers 2

LottieAnimationFunction · 0.90
BriefCardInternalFunction · 0.90

Calls 2

generateQueryKeyFunction · 0.90
fromCDNFunction · 0.90

Tested by

no test coverage detected