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