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

Function updateAdPostInCache

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

Source from the content-addressed store, hash-verified

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