( postId: string, currentData: InfiniteData<Ad>, update: Partial<Post>, )
| 718 | }; |
| 719 | |
| 720 | export const updateAdPostInCache = ( |
| 721 | postId: string, |
| 722 | currentData: InfiniteData<Ad>, |
| 723 | update: Partial<Post>, |
| 724 | ): InfiniteData<Ad> => { |
| 725 | const updatedData = { ...currentData }; |
| 726 | |
| 727 | // Find and update the specific ad that contains the post |
| 728 | updatedData.pages = currentData.pages.map((page: Ad) => { |
| 729 | if (page.data?.post?.id === postId) { |
| 730 | return { |
| 731 | ...page, |
| 732 | data: { |
| 733 | ...page.data, |
| 734 | post: { |
| 735 | ...page.data.post, |
| 736 | ...update, |
| 737 | }, |
| 738 | }, |
| 739 | }; |
| 740 | } |
| 741 | return page; |
| 742 | }); |
| 743 | |
| 744 | return updatedData; |
| 745 | }; |
| 746 | |
| 747 | export const createAdPostRollbackHandler = ( |
| 748 | postId: string, |
no outgoing calls
no test coverage detected