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

Function updateAdPostInCache

packages/shared/src/lib/query.ts:703–728  ·  view source on GitHub ↗
(
  postId: string,
  currentData: InfiniteData<Ad>,
  update: Partial<Post>,
)

Source from the content-addressed store, hash-verified

701};
702
703export const updateAdPostInCache = (
704 postId: string,
705 currentData: InfiniteData<Ad>,
706 update: Partial<Post>,
707): InfiniteData<Ad> => {
708 const updatedData = { ...currentData };
709
710 // Find and update the specific ad that contains the post
711 updatedData.pages = currentData.pages.map((page: Ad) => {
712 if (page.data?.post?.id === postId) {
713 return {
714 ...page,
715 data: {
716 ...page.data,
717 post: {
718 ...page.data.post,
719 ...update,
720 },
721 },
722 };
723 }
724 return page;
725 });
726
727 return updatedData;
728};
729
730export const createAdPostRollbackHandler = (
731 postId: string,

Callers 5

mutateBookmarkFeedPostFunction · 0.90
usePollFunction · 0.90
onUpdateCacheFunction · 0.90
mutateVoteFeedPostFunction · 0.90
updateFeedAndAdsCacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected