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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

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