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