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

Function createAdPostRollbackHandler

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

Source from the content-addressed store, hash-verified

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

Callers 2

mutateBookmarkFeedPostFunction · 0.90
mutateVoteFeedPostFunction · 0.90

Calls 1

rollbackMutationHandlerFunction · 0.85

Tested by

no test coverage detected