( postId: string, currentData: InfiniteData<Ad>, update: Partial<Post>, )
| 672 | }; |
| 673 | |
| 674 | export const updateAdPostInCache = ( |
| 675 | postId: string, |
| 676 | currentData: InfiniteData<Ad>, |
| 677 | update: Partial<Post>, |
| 678 | ): InfiniteData<Ad> => { |
| 679 | const updatedData = { ...currentData }; |
| 680 | |
| 681 | // Find and update the specific ad that contains the post |
| 682 | updatedData.pages = currentData.pages.map((page: Ad) => { |
| 683 | if (page.data?.post?.id === postId) { |
| 684 | return { |
| 685 | ...page, |
| 686 | data: { |
| 687 | ...page.data, |
| 688 | post: { |
| 689 | ...page.data.post, |
| 690 | ...update, |
| 691 | }, |
| 692 | }, |
| 693 | }; |
| 694 | } |
| 695 | return page; |
| 696 | }); |
| 697 | |
| 698 | return updatedData; |
| 699 | }; |
| 700 | |
| 701 | export const createAdPostRollbackHandler = ( |
| 702 | postId: string, |
no outgoing calls
no test coverage detected