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

Function createAdPostRollbackHandler

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

Source from the content-addressed store, hash-verified

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

Callers 2

mutateBookmarkFeedPostFunction · 0.90
mutateVoteFeedPostFunction · 0.90

Calls 1

rollbackMutationHandlerFunction · 0.85

Tested by

no test coverage detected