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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

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