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

Function updateCachedPage

packages/shared/src/lib/query.ts:403–434  ·  view source on GitHub ↗
(
  feedQueryKey: QueryKey,
  queryClient: QueryClient,
  pageIndex: number,
  manipulate: (page: AnyFeedConnection) => AnyFeedConnection,
)

Source from the content-addressed store, hash-verified

401};
402
403export const updateCachedPage = (
404 feedQueryKey: QueryKey,
405 queryClient: QueryClient,
406 pageIndex: number,
407 manipulate: (page: AnyFeedConnection) => AnyFeedConnection,
408): void => {
409 queryClient.setQueryData<InfiniteData<AnyFeedData>>(
410 feedQueryKey,
411 (currentData) => {
412 if (!currentData) {
413 return currentData;
414 }
415
416 const currentPageData = currentData.pages[pageIndex];
417 if (!currentPageData) {
418 return currentData;
419 }
420
421 const { pages } = currentData;
422 const currentPage = structuredClone(currentPageData);
423 currentPage.page = manipulate(
424 currentPage.page as AnyFeedConnection,
425 ) as typeof currentPage.page;
426 const newPages = [
427 ...pages.slice(0, pageIndex),
428 currentPage,
429 ...pages.slice(pageIndex + 1),
430 ];
431 return { pages: newPages, pageParams: currentData.pageParams };
432 },
433 );
434};
435
436export const updateCachedPagePost =
437 (feedQueryKey: QueryKey, queryClient: QueryClient) =>

Callers 2

updateCachedPagePostFunction · 0.85
removeCachedPagePostFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected