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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

711};
712
713export const updateAdPostInCache = (
714 postId: string,
715 currentData: InfiniteData<Ad>,
716 update: Partial<Post>,
717): InfiniteData<Ad> => {
718 const updatedData = { ...currentData };
719
720 // Find and update the specific ad that contains the post
721 updatedData.pages = currentData.pages.map((page: Ad) => {
722 if (page.data?.post?.id === postId) {
723 return {
724 ...page,
725 data: {
726 ...page.data,
727 post: {
728 ...page.data.post,
729 ...update,
730 },
731 },
732 };
733 }
734 return page;
735 });
736
737 return updatedData;
738};
739
740export const createAdPostRollbackHandler = (
741 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