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

Function createAdPostRollbackHandler

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

Source from the content-addressed store, hash-verified

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

Callers 2

mutateBookmarkFeedPostFunction · 0.90
mutateVoteFeedPostFunction · 0.90

Calls 1

rollbackMutationHandlerFunction · 0.85

Tested by

no test coverage detected