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

Function createAdPostRollbackHandler

packages/shared/src/lib/query.ts:700–729  ·  view source on GitHub ↗
(
  postId: string,
  previousState: Partial<Post>,
  rollbackMutationHandler?: (post: Post) => Partial<Post>,
)

Source from the content-addressed store, hash-verified

698};
699
700export const createAdPostRollbackHandler = (
701 postId: string,
702 previousState: Partial<Post>,
703 rollbackMutationHandler?: (post: Post) => Partial<Post>,
704) => {
705 return (currentData: InfiniteData<Ad>): InfiniteData<Ad> => {
706 const updatedData = { ...currentData };
707
708 // Find and update the specific ad that contains the post
709 updatedData.pages = currentData.pages.map((page: Ad) => {
710 if (page.data?.post?.id === postId) {
711 return {
712 ...page,
713 data: {
714 ...page.data,
715 post: {
716 ...page.data.post,
717 ...(rollbackMutationHandler
718 ? rollbackMutationHandler(page.data.post)
719 : previousState),
720 },
721 },
722 };
723 }
724 return page;
725 });
726
727 return updatedData;
728 };
729};
730
731export const updateFeedAndAdsCache = (
732 postId: string,

Callers 2

mutateBookmarkFeedPostFunction · 0.90
mutateVoteFeedPostFunction · 0.90

Calls 1

rollbackMutationHandlerFunction · 0.85

Tested by

no test coverage detected