( postId: string, currentData: InfiniteData<Ad>, update: Partial<Post>, )
| 696 | }; |
| 697 | |
| 698 | export const updateAdPostInCache = ( |
| 699 | postId: string, |
| 700 | currentData: InfiniteData<Ad>, |
| 701 | update: Partial<Post>, |
| 702 | ): InfiniteData<Ad> => { |
| 703 | const updatedData = { ...currentData }; |
| 704 | |
| 705 | // Find and update the specific ad that contains the post |
| 706 | updatedData.pages = currentData.pages.map((page: Ad) => { |
| 707 | if (page.data?.post?.id === postId) { |
| 708 | return { |
| 709 | ...page, |
| 710 | data: { |
| 711 | ...page.data, |
| 712 | post: { |
| 713 | ...page.data.post, |
| 714 | ...update, |
| 715 | }, |
| 716 | }, |
| 717 | }; |
| 718 | } |
| 719 | return page; |
| 720 | }); |
| 721 | |
| 722 | return updatedData; |
| 723 | }; |
| 724 | |
| 725 | export const createAdPostRollbackHandler = ( |
| 726 | postId: string, |
no outgoing calls
no test coverage detected