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

Function createAdPostRollbackHandler

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

Source from the content-addressed store, hash-verified

721};
722
723export const createAdPostRollbackHandler = (
724 postId: string,
725 previousState: Partial<Post>,
726 rollbackMutationHandler?: (post: Post) => Partial<Post>,
727) => {
728 return (currentData: InfiniteData<Ad>): InfiniteData<Ad> => {
729 const updatedData = { ...currentData };
730
731 // Find and update the specific ad that contains the post
732 updatedData.pages = currentData.pages.map((page: Ad) => {
733 if (page.data?.post?.id === postId) {
734 return {
735 ...page,
736 data: {
737 ...page.data,
738 post: {
739 ...page.data.post,
740 ...(rollbackMutationHandler
741 ? rollbackMutationHandler(page.data.post)
742 : previousState),
743 },
744 },
745 };
746 }
747 return page;
748 });
749
750 return updatedData;
751 };
752};
753
754export const updateFeedAndAdsCache = (
755 postId: string,

Callers 2

mutateBookmarkFeedPostFunction · 0.90
mutateVoteFeedPostFunction · 0.90

Calls 1

rollbackMutationHandlerFunction · 0.85

Tested by

no test coverage detected