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