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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

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