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