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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

694};
695
696export const updateAdPostInCache = (
697 postId: string,
698 currentData: InfiniteData<Ad>,
699 update: Partial<Post>,
700): InfiniteData<Ad> => {
701 const updatedData = { ...currentData };
702
703 // Find and update the specific ad that contains the post
704 updatedData.pages = currentData.pages.map((page: Ad) => {
705 if (page.data?.post?.id === postId) {
706 return {
707 ...page,
708 data: {
709 ...page.data,
710 post: {
711 ...page.data.post,
712 ...update,
713 },
714 },
715 };
716 }
717 return page;
718 });
719
720 return updatedData;
721};
722
723export const createAdPostRollbackHandler = (
724 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