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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

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