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

Function createAdPostRollbackHandler

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

Source from the content-addressed store, hash-verified

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

Callers 2

mutateBookmarkFeedPostFunction · 0.90
mutateVoteFeedPostFunction · 0.90

Calls 1

rollbackMutationHandlerFunction · 0.85

Tested by

no test coverage detected