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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

672};
673
674export const updateAdPostInCache = (
675 postId: string,
676 currentData: InfiniteData<Ad>,
677 update: Partial<Post>,
678): InfiniteData<Ad> => {
679 const updatedData = { ...currentData };
680
681 // Find and update the specific ad that contains the post
682 updatedData.pages = currentData.pages.map((page: Ad) => {
683 if (page.data?.post?.id === postId) {
684 return {
685 ...page,
686 data: {
687 ...page.data,
688 post: {
689 ...page.data.post,
690 ...update,
691 },
692 },
693 };
694 }
695 return page;
696 });
697
698 return updatedData;
699};
700
701export const createAdPostRollbackHandler = (
702 postId: string,

Callers 5

mutateBookmarkFeedPostFunction · 0.90
usePollFunction · 0.90
patchBookmarkInCachesFunction · 0.90
mutateVoteFeedPostFunction · 0.90
updateFeedAndAdsCacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected