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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

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